Skip to content
quarry Artifact [20a6fff7d3]
Login

Artifact [20a6fff7d3]

Artifact 20a6fff7d36d9f937dc5ab39b9ea710e5df90077750a308d56e1098ccddb12be:


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)
}