package catalog import "testing" func TestTheFileASourceNamesIsGivenItsPublishedChecksum(t *testing.T) { m := Model{Name: "q", Source: "http://10.0.0.146:8081/q/abc/q4.gguf", Origin: &Origin{Repo: "o/r", Revision: "abc", Files: []OriginFile{{Path: "sub/q4.gguf", SHA256: "aaaa"}, {Path: "config.json"}}}} for src, want := range map[string]string{ m.Source: "aaaa", "https://huggingface.co/o/r/resolve/abc/sub/q4.gguf": "aaaa", "http://10.0.0.146:8081/q/abc/": "", // a set "o/r": "", "http://10.0.0.146:8081/q/abc/config.json": "", // no checksum published } { if got := m.OriginSHA256(src); got != want { t.Errorf("%s: %q, want %q", src, got, want) } } m.Profiles = []Profile{{Name: "cpu", Engine: "llamacpp"}} if ep, ok := m.EngineProfile("cpu"); !ok || ep.ModelSHA256 != "aaaa" { t.Errorf("the node is not told it: %+v", ep) } m.Origin = nil if m.OriginSHA256(m.Source) != "" { t.Error("a checksum with no origin") } }