30 lines
907 B
Bash
30 lines
907 B
Bash
#!/usr/bin/env bats
|
|
|
|
setup() {
|
|
load 'helpers'
|
|
SLUG="${SKILL_SCRIPTS}/slug.sh"
|
|
}
|
|
|
|
@test "slug --raw: flat file remains unchanged" {
|
|
run bash "$SLUG" --raw "raw/articles/il-pane.md"
|
|
[ "$status" -eq 0 ]
|
|
[ "$output" = "il-pane" ]
|
|
}
|
|
|
|
@test "slug --raw: nested file gets folder prefix" {
|
|
run bash "$SLUG" --raw "raw/articles/cibo/il-pane.md"
|
|
[ "$status" -eq 0 ]
|
|
[ "$output" = "cibo-il-pane" ]
|
|
}
|
|
|
|
@test "slug --raw: distinct subdirs avoid collision" {
|
|
s1="$(bash "$SLUG" --raw "raw/articles/cibo/pane.md")"
|
|
s2="$(bash "$SLUG" --raw "raw/articles/storia/pane.md")"
|
|
[ "$s1" != "$s2" ]
|
|
}
|
|
|
|
@test "slug --raw: Bash and Python-calling-bash agree (single implementation)" {
|
|
b="$(bash "$SLUG" --raw "raw/articles/cibo/il-pane.md")"
|
|
p="$(python3 -c "import subprocess;print(subprocess.check_output(['bash','$SLUG','--raw','raw/articles/cibo/il-pane.md'],text=True).strip())")"
|
|
[ "$b" = "$p" ]
|
|
}
|