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

Function TestReadSkillTool

coderd/x/chatd/chattool/skill_test.go:309–717  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

307}
308
309func TestReadSkillTool(t *testing.T) {
310 t.Parallel()
311
312 t.Run("ValidSkill", func(t *testing.T) {
313 t.Parallel()
314
315 ctrl := gomock.NewController(t)
316 conn := agentconnmock.NewMockAgentConn(ctrl)
317
318 skills := []chattool.SkillMeta{{
319 Name: "my-skill",
320 Description: "test",
321 Dir: "/work/.agents/skills/my-skill",
322 }}
323
324 conn.EXPECT().ReadFile(
325 gomock.Any(), gomock.Any(), int64(0), gomock.Any(),
326 ).Return(
327 io.NopCloser(strings.NewReader(validSkillMD("my-skill", "test"))),
328 "text/markdown",
329 nil,
330 )
331 conn.EXPECT().LS(gomock.Any(), "", gomock.Any()).Return(
332 workspacesdk.LSResponse{
333 Contents: []workspacesdk.LSFile{
334 {Name: "SKILL.md"},
335 },
336 }, nil,
337 )
338
339 tool := chattool.ReadSkill(chattool.ReadSkillOptions{
340 GetWorkspaceConn: func(context.Context) (workspacesdk.AgentConn, error) {
341 return conn, nil
342 },
343 GetSkills: func() []chattool.SkillMeta { return skills },
344 })
345
346 resp, err := tool.Run(context.Background(), fantasy.ToolCall{
347 ID: "call-1",
348 Name: "read_skill",
349 Input: `{"name":"my-skill"}`,
350 })
351 require.NoError(t, err)
352 assert.False(t, resp.IsError)
353 assert.Contains(t, resp.Content, "Do the thing.")
354 })
355
356 t.Run("PersonalSkill", func(t *testing.T) {
357 t.Parallel()
358
359 tool := chattool.ReadSkill(chattool.ReadSkillOptions{
360 ResolveAlias: func(alias string) (skillspkg.ResolvedSkill, error) {
361 require.Equal(t, "my-skill", alias)
362 return skillspkg.ResolvedSkill{
363 Skill: skillspkg.Skill{
364 Name: "my-skill",
365 Description: "test",
366 Source: skillspkg.SourcePersonal,

Callers

nothing calls this directly

Calls 12

EXPECTMethod · 0.95
NewMockAgentConnFunction · 0.92
ReadSkillFunction · 0.92
validSkillMDFunction · 0.85
responseNameFunction · 0.85
FatalMethod · 0.80
RunMethod · 0.65
ReadFileMethod · 0.65
LSMethod · 0.65
NewMethod · 0.65
ContainsMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected