package api
import "testing"
// A cached archive is keyed by who produced it, not only by what it
// contains. zit's container format changes between releases — 0.3.25
// began flagging zip names as UTF-8 — and a key without the producer
// kept serving the old container for every check-in already cached,
// so the upstream fix never reached a reader (620e562f).
func TestAnArchiveKeyChangesWhenTheProducerDoes(t *testing.T) {
old := archiveKey("alpha", "zit 0.3.24", "abc123", "zip")
cur := archiveKey("alpha", "zit 0.3.25", "abc123", "zip")
if old == cur {
t.Fatalf("FAIL: the same key for two producers: %q", cur)
}
if archiveKey("alpha", "zit 0.3.25", "abc123", "zip") != cur {
t.Fatal("FAIL: the key is not stable for identical inputs")
}
if archiveKey("alpha", "zit 0.3.25", "abc123", "tar") == cur {
t.Fatal("FAIL: two containers share a key")
}
if archiveKey("beta", "zit 0.3.25", "abc123", "zip") == cur {
t.Fatal("FAIL: two repositories share a key")
}
t.Logf("ok: %q vs %q", old, cur)
}