MCPcopy Index your code
hub / github.com/coder/coder / TestReadTemplate_NoPresets

Function TestReadTemplate_NoPresets

coderd/x/chatd/chattool/readtemplate_test.go:143–183  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

141}
142
143func TestReadTemplate_NoPresets(t *testing.T) {
144 t.Parallel()
145
146 db, _ := dbtestutil.NewDB(t)
147 user := dbgen.User(t, db, database.User{})
148 org := dbgen.Organization(t, db, database.Organization{})
149 _ = dbgen.OrganizationMember(t, db, database.OrganizationMember{
150 UserID: user.ID,
151 OrganizationID: org.ID,
152 })
153
154 tv := dbgen.TemplateVersion(t, db, database.TemplateVersion{
155 OrganizationID: org.ID,
156 CreatedBy: user.ID,
157 })
158 tmpl := dbgen.Template(t, db, database.Template{
159 OrganizationID: org.ID,
160 CreatedBy: user.ID,
161 ActiveVersionID: tv.ID,
162 })
163
164 ctx := testutil.Context(t, testutil.WaitShort)
165 tool := chattool.ReadTemplate(db, org.ID, chattool.ReadTemplateOptions{
166 OwnerID: user.ID,
167 })
168
169 resp, err := tool.Run(ctx, fantasy.ToolCall{
170 ID: "call-2",
171 Name: "read_template",
172 Input: `{"template_id":"` + tmpl.ID.String() + `"}`,
173 })
174 require.NoError(t, err)
175 require.False(t, resp.IsError)
176
177 var result map[string]any
178 require.NoError(t, json.Unmarshal([]byte(resp.Content), &result))
179
180 // Presets key should be absent when there are no presets.
181 _, hasPresets := result["presets"]
182 require.False(t, hasPresets, "presets key should be absent when there are none")
183}

Callers

nothing calls this directly

Calls 11

NewDBFunction · 0.92
UserFunction · 0.92
OrganizationFunction · 0.92
OrganizationMemberFunction · 0.92
TemplateVersionFunction · 0.92
TemplateFunction · 0.92
ContextFunction · 0.92
ReadTemplateFunction · 0.92
RunMethod · 0.65
StringMethod · 0.45
UnmarshalMethod · 0.45

Tested by

no test coverage detected