71 lines
2 KiB
Bash
71 lines
2 KiB
Bash
#!/usr/bin/env bats
|
|
# tests/lint.bats — lib/lint.sh validators and the scoped-lint wrapper.
|
|
load helpers
|
|
|
|
setup() {
|
|
source "$LIB_DIR/output.sh"
|
|
source "$LIB_DIR/lint.sh"
|
|
}
|
|
|
|
write_page() { # write_page <path> <type> <domain>
|
|
cat > "$1" <<EOF
|
|
---
|
|
title: "T"
|
|
type: $2
|
|
domain: $3
|
|
tags: [x]
|
|
maturity: draft
|
|
last_updated: $(date +%F)
|
|
private: false
|
|
---
|
|
body
|
|
EOF
|
|
}
|
|
|
|
@test "lint_markdown_file: a clean page passes (0 errors)" {
|
|
G="$(make_fixture_genome)"
|
|
write_page "$G/wiki/sources/good.md" source genome-test
|
|
run lint_markdown_file "$G/wiki/sources/good.md" genome-test
|
|
[ "$status" -eq 0 ]
|
|
}
|
|
|
|
@test "lint_markdown_file: invalid type + wrong domain are caught" {
|
|
G="$(make_fixture_genome)"
|
|
write_page "$G/wiki/sources/bad.md" banana wrong-genome
|
|
run lint_markdown_file "$G/wiki/sources/bad.md" genome-test
|
|
[ "$status" -ne 0 ]
|
|
}
|
|
|
|
@test "check_privacy_consistency: a private/ file without 'private: true' fails" {
|
|
G="$(make_fixture_genome)"
|
|
# page sits in wiki/private/ but is flagged private: false → leak
|
|
write_page "$G/wiki/private/p.md" private genome-test
|
|
run check_privacy_consistency "$G/wiki/private/p.md"
|
|
[ "$status" -ne 0 ]
|
|
}
|
|
|
|
@test "check_page_size: a >800-line page errors" {
|
|
G="$(make_fixture_genome)"
|
|
{ write_page "$G/wiki/sources/big.md" source genome-test; yes "x" | head -n 850 >> "$G/wiki/sources/big.md"; }
|
|
run check_page_size "$G/wiki/sources/big.md"
|
|
[ "$status" -ne 0 ]
|
|
}
|
|
|
|
@test "scoped-lint: aggregates findings and exits non-zero on errors" {
|
|
G="$(make_fixture_genome)"
|
|
write_page "$G/wiki/sources/bad.md" banana wrong-genome
|
|
cd "$G"
|
|
export KG_LIB_DIR="$LIB_DIR"
|
|
run bash "$SKILL_SCRIPTS/scoped-lint.sh" genome-test wiki/sources/bad.md
|
|
[ "$status" -ne 0 ]
|
|
[[ "$output" == *"error(s)"* ]]
|
|
}
|
|
|
|
@test "scoped-lint: a clean page passes (exit 0)" {
|
|
G="$(make_fixture_genome)"
|
|
write_page "$G/wiki/sources/good.md" source genome-test
|
|
cd "$G"
|
|
export KG_LIB_DIR="$LIB_DIR"
|
|
run bash "$SKILL_SCRIPTS/scoped-lint.sh" genome-test wiki/sources/good.md
|
|
[ "$status" -eq 0 ]
|
|
}
|