2d25e69632
Isolated per-test $HOME sandboxing via tests/helpers/common.bash. Covers both plugins' wrapper scripts, their setup.sh, and git-manager's two PreToolUse hooks (53 tests). Verified the suite catches regressions by temporarily reintroducing the recently-fixed vault_search.sh -g/-- ordering bug and confirming it fails.
48 lines
1.2 KiB
Bash
48 lines
1.2 KiB
Bash
#!/usr/bin/env bats
|
|
# Tests for skills/obsidian-vault-kb/scripts/vault_index.sh.
|
|
|
|
load '../helpers/common'
|
|
|
|
setup() {
|
|
sandbox_home
|
|
SCRIPT="$REPO_ROOT/skills/obsidian-vault-kb/scripts/vault_index.sh"
|
|
CONFIG_FILE="$HOME/.agent-skills/obsidian-vault-kb/config.json"
|
|
VAULT="$BATS_TEST_TMPDIR/vault"
|
|
make_test_vault "$VAULT"
|
|
write_vault_config "$CONFIG_FILE" "append" "v=$VAULT"
|
|
}
|
|
|
|
@test "folder structure excludes .obsidian and .git" {
|
|
run "$SCRIPT" v
|
|
[ "$status" -eq 0 ]
|
|
[[ "$output" == *"/Notes"* ]]
|
|
[[ "$output" != *".obsidian"* ]]
|
|
[[ "$output" != *"/.git"* ]]
|
|
}
|
|
|
|
@test "note count per top-level folder counts only .md files" {
|
|
run "$SCRIPT" v
|
|
[ "$status" -eq 0 ]
|
|
[[ "$output" == *"Notes: 2"* ]]
|
|
}
|
|
|
|
@test "frontmatter tags are extracted and deduplicated" {
|
|
run "$SCRIPT" v
|
|
[ "$status" -eq 0 ]
|
|
for tag in dns homelab networking overview; do
|
|
[[ "$output" == *"$tag"* ]]
|
|
done
|
|
}
|
|
|
|
@test "a note matching *overview* is flagged as a possible MOC file" {
|
|
run "$SCRIPT" v
|
|
[ "$status" -eq 0 ]
|
|
[[ "$output" == *"homelab-overview.md"* ]]
|
|
}
|
|
|
|
@test "unknown vault name errors" {
|
|
run "$SCRIPT" not-a-real-vault
|
|
[ "$status" -eq 1 ]
|
|
[[ "$output" == *"no vault named"* ]]
|
|
}
|