MCPcopy Create free account
hub / github.com/cel-expr/cel-go / TestPromptTemplate

Function TestPromptTemplate

cel/prompt_test.go:60–103  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

58}
59
60func TestPromptTemplate(t *testing.T) {
61 tests := []struct {
62 name string
63 envOpts []EnvOption
64 out string
65 }{
66 {
67 name: "basic",
68 out: wantBasicPrompt,
69 },
70 {
71 name: "macros",
72 envOpts: []EnvOption{Macros(StandardMacros...)},
73 out: wantMacrosPrompt,
74 },
75 {
76 name: "standard_env",
77 envOpts: []EnvOption{StdLib(StdLibSubset(env.NewLibrarySubset().SetDisableMacros(true)))},
78 out: wantStandardEnvPrompt,
79 },
80 }
81
82 for _, tst := range tests {
83 tc := tst
84 t.Run(tc.name, func(t *testing.T) {
85 envOpts := append([]EnvOption{TypeDescs(testFds(t))}, tc.envOpts...)
86
87 env, err := NewCustomEnv(
88 envOpts...,
89 )
90 if err != nil {
91 t.Fatalf("cel.NewCustomEnv() failed: %v", err)
92 }
93 prompt, err := AuthoringPrompt(env)
94 if err != nil {
95 t.Fatalf("cel.AuthoringPrompt() failed: %v", err)
96 }
97 out := prompt.Render("<USER_PROMPT>")
98 if diff := cmp.Diff(tc.out, out); diff != "" {
99 t.Errorf("got %s, diff (-want +got): %s", out, diff)
100 }
101 })
102 }
103}
104
105func TestPromptTemplateFieldPaths(t *testing.T) {
106 tests := []struct {

Callers

nothing calls this directly

Calls 9

StdLibFunction · 0.85
StdLibSubsetFunction · 0.85
TypeDescsFunction · 0.85
testFdsFunction · 0.85
NewCustomEnvFunction · 0.85
AuthoringPromptFunction · 0.85
SetDisableMacrosMethod · 0.80
RenderMethod · 0.80
MacrosFunction · 0.70

Tested by

no test coverage detected