zk/tests/test__zk_list.sh

38 lines
884 B
Bash
Raw Normal View History

2023-12-08 16:08:34 +00:00
#!/bin/bash
TMP_ZETTELKASTEN=""
setup() {
source ../zk
TMP_ZETTELKASTEN="$(mktemp -d)"
}
teardown() {
rm -rf "$TMP_ZETTELKASTEN"
}
test__zk_list_outputs_correct_format_with_one_zettel() {
export ZKDIR="$TMP_ZETTELKASTEN"
test_zettel="aaaaaaaaaaaaaa"
echo "# Test Zettel" > "$TMP_ZETTELKASTEN/$test_zettel"
result="$(_zk_list)"
expected="$test_zettel | # Test Zettel"
assert_equals "$expected" "$result"
}
test__zk_list_outputs_correct_format_with_multiple_zettels() {
export ZKDIR="$TMP_ZETTELKASTEN"
test_zettel1="aaaaaaaaaaaaaa"
test_zettel2="bbbbbbbbbbbbbb"
echo "# Test Zettel 1" > "$TMP_ZETTELKASTEN/$test_zettel1"
echo "# Test Zettel 2" > "$TMP_ZETTELKASTEN/$test_zettel2"
result="$(_zk_list)"
expected="$test_zettel1 | # Test Zettel 1
$test_zettel2 | # Test Zettel 2"
assert_equals "$expected" "$result"
}