package catalog import ( "testing" "gitea.mynodes.xyz/ilker/llmgw/internal/comfy" ) func TestEveryPresetIsACatalogEntryThatLoads(t *testing.T) { var models []Model for _, p := range Presets() { models = append(models, p.Model) } cat, err := New(models) if err != nil { t.Fatal(err) } for _, p := range Presets() { m, ok := cat.Resolve(p.Model.Name) if !ok { t.Fatalf("%s is not in the catalog", p.Model.Name) } if p.Makes == OutputMeshes && !m.MakesMeshes() || p.Makes == OutputPictures && !m.MakesImages() { t.Errorf("%s does not make %s", m.Name, p.Makes) } // A shipped entry has its workflow inside llmgw, not in a file a // site would have to write. w, ckpt := m.ComfyWorkflow() if _, err := comfy.Load(w); err != nil { t.Errorf("%s: %v", m.Name, err) } if ckpt == "" { t.Errorf("%s has no checkpoint", m.Name) } if m.License == nil || m.License.ID == "" || m.License.Commercial == nil { t.Errorf("%s does not say its licence for a machine to match", m.Name) } for _, pr := range m.Profiles { if pr.GPUClass != "" || pr.GPU == nil { t.Errorf("%s/%s names a class: a preset fits any site's cards", m.Name, pr.Name) } } } } func TestAPresetIsFoundByName(t *testing.T) { if p, ok := PresetNamed("triposr"); !ok || p.Model.ComfyUI.Workflow != "triposr" { t.Errorf("triposr: %+v %v", p, ok) } if _, ok := PresetNamed("sdxl"); ok { t.Error("a preset that is not there was found") } // Each call is a fresh copy: a caller changing one changes nobody's. a, _ := PresetNamed("triposr") a.Model.ComfyUI.Nodes[0].Requirements[0] = "x" if b, _ := PresetNamed("triposr"); b.Model.ComfyUI.Nodes[0].Requirements[0] == "x" { t.Error("a preset was changed by a caller") } }