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

Function TestPromptTemplateFieldPaths

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

Source from the content-addressed store, hash-verified

103}
104
105func TestPromptTemplateFieldPaths(t *testing.T) {
106 tests := []struct {
107 name string
108 envOpts []EnvOption
109 out string
110 }{
111 {
112 name: "standard_env",
113 envOpts: []EnvOption{
114 VariableWithDoc("team", ObjectType("cel.testdata.Team"),
115 common.MultilineDescription("A team of gifted youngsters")),
116 StdLib(StdLibSubset(env.NewLibrarySubset().SetDisableMacros(true))),
117 },
118 out: wantFieldPathsPrompt,
119 },
120 }
121
122 for _, tst := range tests {
123 tc := tst
124 t.Run(tc.name, func(t *testing.T) {
125 envOpts := append([]EnvOption{TypeDescs(testFds(t))}, tc.envOpts...)
126
127 env, err := NewCustomEnv(
128 envOpts...,
129 )
130 if err != nil {
131 t.Fatalf("cel.NewCustomEnv() failed: %v", err)
132 }
133 prompt, err := AuthoringPromptWithFieldPaths(env)
134 if err != nil {
135 t.Fatalf("cel.AuthoringPromptWithFieldPaths() failed: %v", err)
136 }
137 out := prompt.Render("<USER_PROMPT>")
138 if diff := cmp.Diff(tc.out, out); diff != "" {
139 t.Errorf("got %s, diff (-want +got): %s", out, diff)
140 }
141 })
142 }
143}
144
145// TestRenderSanitizesTemplateDirectives verifies that user-supplied input containing
146// Go text/template action delimiters is rendered as literal text and never executed

Callers

nothing calls this directly

Calls 10

MultilineDescriptionFunction · 0.92
VariableWithDocFunction · 0.85
StdLibFunction · 0.85
StdLibSubsetFunction · 0.85
TypeDescsFunction · 0.85
testFdsFunction · 0.85
NewCustomEnvFunction · 0.85
SetDisableMacrosMethod · 0.80
RenderMethod · 0.80

Tested by

no test coverage detected