test(ingest): Add Bats tests for core skill scripts
This commit is contained in:
parent
ff0828f5a7
commit
9b61e74821
1 changed files with 53 additions and 0 deletions
53
tests/scripts.bats
Normal file
53
tests/scripts.bats
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
#!/usr/bin/env bats
|
||||
# tests/scripts.bats — unit tests for the deterministic skill scripts.
|
||||
load helpers
|
||||
|
||||
@test "slug: path with extension and spaces" {
|
||||
run bash "$SKILL_SCRIPTS/slug.sh" "raw/articles/My Test Source.md"
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$output" = "my-test-source" ]
|
||||
}
|
||||
|
||||
@test "slug: punctuation and repeats collapse to single hyphens" {
|
||||
run bash "$SKILL_SCRIPTS/slug.sh" "Qualche Concetto!! Strano"
|
||||
[ "$output" = "qualche-concetto-strano" ]
|
||||
}
|
||||
|
||||
@test "log-append: appends a well-formed INGEST entry with a run_id" {
|
||||
G="$(make_fixture_genome)"; cd "$G"
|
||||
run bash "$SKILL_SCRIPTS/log-append.sh" --type INGEST --subject foo --model m \
|
||||
--context "[[raw/x]]" --output "[[sources/foo]]" --reasoning "why"
|
||||
[ "$status" -eq 0 ]
|
||||
grep -q "INGEST | foo" wiki/log.md
|
||||
grep -q '^- run_id: `' wiki/log.md
|
||||
grep -q '^- model: `m`' wiki/log.md
|
||||
}
|
||||
|
||||
@test "log-append: rejects an invalid TYPE" {
|
||||
G="$(make_fixture_genome)"; cd "$G"
|
||||
run bash "$SKILL_SCRIPTS/log-append.sh" --type BOGUS --subject foo
|
||||
[ "$status" -ne 0 ]
|
||||
}
|
||||
|
||||
@test "index-append: inserts under the right section and keeps it sorted" {
|
||||
G="$(make_fixture_genome)"; cd "$G"
|
||||
python3 "$SKILL_SCRIPTS/index-append.py" --section Sources --entry '- [[sources/zzz]] — z. `maturity: draft`'
|
||||
python3 "$SKILL_SCRIPTS/index-append.py" --section Sources --entry '- [[sources/aaa]] — a. `maturity: draft`'
|
||||
a=$(grep -n 'sources/aaa' wiki/index.md | cut -d: -f1)
|
||||
z=$(grep -n 'sources/zzz' wiki/index.md | cut -d: -f1)
|
||||
[ -n "$a" ] && [ -n "$z" ]
|
||||
[ "$a" -lt "$z" ]
|
||||
}
|
||||
|
||||
@test "index-append: bumps frontmatter last_updated to today" {
|
||||
G="$(make_fixture_genome)"; cd "$G"
|
||||
python3 "$SKILL_SCRIPTS/index-append.py" --section Concepts --entry '- [[concepts/x]] — x. `maturity: draft`'
|
||||
grep -q "^last_updated: $(date +%F)$" wiki/index.md
|
||||
}
|
||||
|
||||
@test "index-append: is idempotent for the same entry" {
|
||||
G="$(make_fixture_genome)"; cd "$G"
|
||||
python3 "$SKILL_SCRIPTS/index-append.py" --section Sources --entry '- [[sources/dup]] — d. `maturity: draft`'
|
||||
python3 "$SKILL_SCRIPTS/index-append.py" --section Sources --entry '- [[sources/dup]] — d. `maturity: draft`'
|
||||
[ "$(grep -c 'sources/dup' wiki/index.md)" -eq 1 ]
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue