package core import ( "strings" "testing" ) // The site revision is the site-level analogue of RepoInfo.GPGKeyring: it // must be part of contentIdentity or a notice change cannot invalidate the // module cache or the response ETag. func TestContentIdentityIncludesSiteRevision(t *testing.T) { a := NewCtx(&Site{RevFn: func() string { return "rev-a" }}, nil, RepoInfo{}, "main") b := NewCtx(&Site{RevFn: func() string { return "rev-b" }}, nil, RepoInfo{}, "main") a.Commit, b.Commit = "sha", "sha" if a.contentIdentity() == b.contentIdentity() { t.Fatal("site revision is not part of contentIdentity") } } // Tests construct bare *Ctx values (see blob_test.go) and LoadTemplates // parses with &Ctx{}; contentIdentity must tolerate a nil Site. func TestContentIdentityNilSite(t *testing.T) { got := (&Ctx{}).contentIdentity() if !strings.HasPrefix(got, "|") { t.Fatalf("contentIdentity() = %q", got) } }