test: lab 30 checks that each tier has its own chezmoi state

The private init's --persistent-state (chezmoistate-private.boltdb) and its
unit assertion landed in 06b03c9. chezmoi keeps its state next to the config
file, so the tiers used to share chezmoistate.boltdb and each wrote its
config-template hash over the other's: after the private init every public
command warned "config file template has changed".

Lab 30 now asserts the private state file exists, private.toml names it, and
neither tier warns and both statuses are clean after both inits. The fake
private tier is resynced with the real template and cmp alias.
This commit is contained in:
bcherb2 committed 2026-11-18 03:03:24 -05:00
1 parent 0279d4a5d0
commit 28bcea9850
3 files changed
+43 -3

No files matched your search

+20
View File
@@ -202,4 +202,24 @@ git config --get 'url.git@github.com:.pushinsteadof' >/dev/null 2>&1 \
|| fail "the GitHub push-over-ssh rewrite is gone entirely"
ok "GitHub reads stay https; only pushes are rewritten to ssh"
# ---- two tiers, two state files: neither warns about the other --------------
# Both tiers used to share ~/.config/chezmoi/chezmoistate.boltdb, and each wrote
# its config-template hash over the other's, so after this init every public
# command said "config file template has changed". `run_` scripts always show
# as " R"; anything else in either status is drift.
CZ=$HOME/.config/chezmoi
[ -f "$CZ/chezmoistate-private.boltdb" ] || fail "the private tier has no state file of its own"
grep -q '^persistentState = ' "$CZ/private.toml" || fail "private.toml does not name its state file"
pub=$(chezmoi status 2>&1)
prv=$(chezmoi -S "$HOME/.local/share/dotfiles-private" -c "$CZ/private.toml" \
--persistent-state "$CZ/chezmoistate-private.boltdb" status 2>&1)
for t in pub prv; do
eval "o=\$$t"
case $o in *"template has changed"*|*warning*)
printf '%s\n' "$o" | sed 's/^/ | /'; fail "$t tier warns after both inits" ;; esac
d=$(printf '%s\n' "$o" | grep -v '^ R ' | grep -v '^$' || true)
[ -z "$d" ] || { printf '%s\n' "$d" | sed 's/^/ | /'; fail "$t tier status is not clean"; }
done
ok "each tier has its own state file; neither warns and both statuses are clean"
echo "PRIVATE TIER PASS"