blob: e6ffc21c8db1b2246e43dcbfee38ec095ee2fb8d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#!/usr/bin/env bats
# Tests for the flashcard-sync wrapper: argument handling + the stats gate.
# The clean end-to-end path runs flashcard-to-anki.py (uv-resolved genanki) and is
# not exercised here; these cover the guard paths that stop before that step.
setup() {
SCRIPT_DIR="$(cd "$(dirname "$BATS_TEST_FILENAME")/.." && pwd)"
SYNC="$SCRIPT_DIR/flashcard-sync"
STATS="$SCRIPT_DIR/flashcard-stats.py"
TMP="$(mktemp -d)"
}
teardown() {
rm -rf "$TMP"
}
@test "flashcard-sync: no args exits 2" {
run "$SYNC"
[ "$status" -eq 2 ]
}
@test "flashcard-sync: missing source file exits 2" {
run "$SYNC" "$TMP/nope.org"
[ "$status" -eq 2 ]
}
@test "flashcard-sync: stats gate failure exits 1 and writes no apkg" {
cat > "$TMP/dirty.org" <<'EOF'
#+TITLE: DeepSat Org-Drill Flashcards
* Section
** DeepSat :drill:
*** Answer
A satellite company.
EOF
run "$SYNC" "$TMP/dirty.org"
[ "$status" -eq 1 ]
[ ! -f "$HOME/sync/phone/anki/dirty.apkg" ]
}
@test "flashcard-stats: a multi-tagged :fundamental:drill: card still counts" {
# Regression guard: a curated card carrying a second org tag must not drop
# from the count. A :drill:$ anchor would have counted only one card here.
cat > "$TMP/multitag.org" <<'EOF'
#+TITLE: Multitag Test
* Orbital Regimes
** What is LEO? :fundamental:drill:
:PROPERTIES:
:ID: c1
:END:
Low Earth Orbit is the region below about 2000 kilometers.
** What is GEO? :drill:
:PROPERTIES:
:ID: c2
:END:
Geostationary orbit sits at roughly 35786 kilometers of altitude.
EOF
run python3 "$STATS" "$TMP/multitag.org"
[ "$status" -eq 0 ]
[[ "$output" == *"Cards: 2"* ]]
[[ "$output" == *clean* ]]
}
|