Artifact 423b4582cd34869418f77329a4246121b00922d1d968942c2b5d7bc3b6edb211:
- File
internal/zitcli/pull_test.go
— part of check-in
[9c7b4cff5b]
at
2026-08-17 18:02:31
on branch trunk
— fleet: mirror upstreams on a schedule
Adds mirror.list/set/delete/run ops (admin), a mirror table in OLTP, and a scheduler that pulls each configured store on its own interval. Pulls run under the store's single-writer lease and re-ingest only when artifacts actually arrived.
zitcli.Pull is the one call that cannot pass -R: zit pull refuses the flag and works by working directory. pullChanged reads zit's result positively and errors on an unrecognized line rather than defaulting to 'nothing changed', which would leave a mirror green while it silently stopped tracking. (user: dmestas, size: 1448) [annotate] [blame] [check-ins using]
package zitcli import "testing" // The strings here are REAL zit output, captured by serving one copy of // a store and pulling into another. They are the contract between zit's // wording and quarry's mirror scheduler, and this test is what turns a // wording change from a silent stale mirror into a build failure. func TestPullChangedReadsRealZitOutput(t *testing.T) { for _, tc := range []struct { name string out string want bool }{ {"nothing new", "already up to date\n", false}, {"artifacts arrived", "received 2 artifacts in 2 rounds\n", true}, {"a larger fetch", "received 1409 artifacts in 7 rounds\n", true}, } { got, err := pullChanged([]byte(tc.out)) if err != nil { t.Errorf("%s: %v", tc.name, err) continue } if got != tc.want { t.Errorf("%s: changed = %v, want %v", tc.name, got, tc.want) } } } // An unrecognized result must be an ERROR, never a quiet false. A quiet // false is a mirror that reports success, never re-indexes, and shows // green on the fleet page while drifting arbitrarily far from upstream. func TestPullChangedRefusesToGuess(t *testing.T) { for _, out := range []string{ "", "fetched 3 artifacts", // a plausible future rewording "synchronized with peer", // ditto "nothing to do", // ditto } { if _, err := pullChanged([]byte(out)); err == nil { t.Errorf("pullChanged(%q) returned no error — an unknown result was guessed at", out) } } }