package aiprompts import "testing" func TestRender_replacesKnownVars(t *testing.T) { t.Parallel() got := Render("Hello {{name}} in {{category}}", Vars{ "name": "Widget", "category": "Tools", }) want := "Hello Widget in Tools" if got != want { t.Fatalf("got %q want %q", got, want) } } func TestRender_unknownVarEmpty(t *testing.T) { t.Parallel() got := Render("X={{missing}}Y", Vars{"name": "a"}) if got != "X=Y" { t.Fatalf("got %q", got) } } func TestRender_whitespaceInBraces(t *testing.T) { t.Parallel() got := Render("{{ name }}", Vars{"name": "ok"}) if got != "ok" { t.Fatalf("got %q", got) } } func TestExtractVariables(t *testing.T) { t.Parallel() got := ExtractVariables("{{name}} and {{name}} then {{brand_voice}}") if len(got) != 2 || got[0] != "name" || got[1] != "brand_voice" { t.Fatalf("got %#v", got) } } func TestValidPromptKey(t *testing.T) { t.Parallel() if !ValidPromptKey(KeyProductEnhance) { t.Fatal("expected product_enhance valid") } if ValidPromptKey("nope") { t.Fatal("expected nope invalid") } }