package zitcli
import (
"testing"
)
// zit 0.11 exits 9 from a pull that succeeded and brought a fork. That
// is a successful pull with a merge pending upstream, so the mirror
// reports a change instead of failing; a real failure (1) still fails.
func TestAPullThatBringsAForkIsASuccess(t *testing.T) {
dir := t.TempDir()
fakeZit(t, `echo "received 12 artifacts"; echo "fork on trunk: 2 leaves (abc, def)" >&2; exit 9`)
changed, err := New(dir).Pull(testToken, "https://upstream.example/r/x")
if err != nil || !changed {
t.Fatalf("FAIL: exit 9 = changed %v, err %v; want a successful pull that changed the store", changed, err)
}
fakeZit(t, `echo "pull: connection refused" >&2; exit 1`)
if _, err := New(dir).Pull(testToken, "https://upstream.example/r/x"); err == nil {
t.Fatal("FAIL: exit 1 was taken as success")
}
t.Log("ok: 9 is a pull with a fork, 1 is still a failure")
}