(t *testing.T)
| 307 | } |
| 308 | |
| 309 | func 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, |
nothing calls this directly
no test coverage detected