package agentmodel import "testing" // TestValidate is what the settings PATCH relies on to reject a typo at save // time rather than on the next chat turn. func TestValidate(t *testing.T) { if err := Validate("k", "ollama-cloud/glm-5.2:cloud"); err != nil { t.Errorf("valid spec rejected: %v", err) } // No key needed to validate — Parse resolves the provider, it doesn't call it. if err := Validate("", "ollama-cloud/glm-5.2:cloud"); err != nil { t.Errorf("valid spec rejected without a key: %v", err) } // A comma-separated failover chain is majordomo grammar and must resolve. if err := Validate("k", "ollama-cloud/glm-5.2:cloud,ollama-cloud/kimi-k2.6:cloud"); err != nil { t.Errorf("failover chain rejected: %v", err) } for _, bad := range []string{"", " ", "nonesuch/model"} { if err := Validate("k", bad); err == nil { t.Errorf("Validate accepted %q", bad) } } } // TestResolveReturnsAModel confirms a good spec yields a usable model handle. func TestResolveReturnsAModel(t *testing.T) { m, err := Resolve("k", "ollama-cloud/glm-5.2:cloud") if err != nil { t.Fatalf("resolve: %v", err) } if m == nil { t.Fatal("resolve returned a nil model with no error") } }