53 lines
2.1 KiB
Bash
53 lines
2.1 KiB
Bash
#!/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 ]
|
|
}
|