package templates import ( "reflect" "testing" ) func TestAll_SeedComplete(t *testing.T) { want := []string{ "anthropic-official", "openrouter", "deepseek", "moonshot", "zhipu", "custom-base", } got := All() if len(got) != len(want) { t.Fatalf("template count: got %d, want %d", len(got), len(want)) } have := map[string]bool{} for _, tpl := range got { if tpl.Description == "" { t.Errorf("%q: missing description", tpl.Name) } if len(tpl.Env) == 0 { t.Errorf("%q: empty env", tpl.Name) } for _, e := range tpl.Env { if e.Name == "" { t.Errorf("%q: empty env key name", tpl.Name) } } have[tpl.Name] = true } for _, n := range want { if !have[n] { t.Errorf("missing seed template %q", n) } } } func TestGet(t *testing.T) { tpl, ok := Get("openrouter") if !ok { t.Fatal("openrouter missing") } if tpl.Name != "openrouter" { t.Errorf("name: %q", tpl.Name) } if _, ok := Get("nonexistent"); ok { t.Error("nonexistent template should miss") } } func TestNamesSorted(t *testing.T) { got := Names() want := []string{ "anthropic-official", "custom-base", "deepseek", "moonshot", "openrouter", "zhipu", } if !reflect.DeepEqual(got, want) { t.Errorf("sorted names: got %v want %v", got, want) } } func TestParseInvalid(t *testing.T) { cases := []string{ `templates: - name: "" env: - name: K`, `templates: - name: ok env: []`, `templates: - name: ok env: - name: ""`, } for i, c := range cases { if _, err := Parse([]byte(c)); err == nil { t.Errorf("case %d: expected error, got nil", i) } } }