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

Function TestReadSkillFileTool

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

Source from the content-addressed store, hash-verified

730}
731
732func TestReadSkillFileTool(t *testing.T) {
733 t.Parallel()
734
735 t.Run("ValidFile", func(t *testing.T) {
736 t.Parallel()
737
738 ctrl := gomock.NewController(t)
739 conn := agentconnmock.NewMockAgentConn(ctrl)
740
741 skills := []chattool.SkillMeta{{
742 Name: "my-skill",
743 Dir: "/work/.agents/skills/my-skill",
744 }}
745
746 conn.EXPECT().ReadFile(
747 gomock.Any(),
748 "/work/.agents/skills/my-skill/roles/reviewer.md",
749 int64(0),
750 int64(512*1024+1),
751 ).Return(
752 io.NopCloser(strings.NewReader("reviewer guide")),
753 "text/markdown",
754 nil,
755 )
756
757 tool := chattool.ReadSkillFile(chattool.ReadSkillOptions{
758 GetWorkspaceConn: func(context.Context) (workspacesdk.AgentConn, error) {
759 return conn, nil
760 },
761 GetSkills: func() []chattool.SkillMeta { return skills },
762 })
763
764 resp, err := tool.Run(context.Background(), fantasy.ToolCall{
765 ID: "call-1",
766 Name: "read_skill_file",
767 Input: `{"name":"my-skill","path":"roles/reviewer.md"}`,
768 })
769 require.NoError(t, err)
770 assert.False(t, resp.IsError)
771 assert.Contains(t, resp.Content, "reviewer guide")
772 })
773
774 t.Run("PersonalSkillUnsupported", func(t *testing.T) {
775 t.Parallel()
776
777 tool := chattool.ReadSkillFile(chattool.ReadSkillOptions{
778 ResolveAlias: func(alias string) (skillspkg.ResolvedSkill, error) {
779 return skillspkg.ResolvedSkill{
780 Skill: skillspkg.Skill{Name: alias, Source: skillspkg.SourcePersonal},
781 Alias: alias,
782 }, nil
783 },
784 })
785
786 resp, err := tool.Run(context.Background(), fantasy.ToolCall{
787 ID: "call-1",
788 Name: "read_skill_file",
789 Input: `{"name":"my-skill","path":"helper.md"}`,

Callers

nothing calls this directly

Calls 8

EXPECTMethod · 0.95
NewMockAgentConnFunction · 0.92
ReadSkillFileFunction · 0.92
FatalMethod · 0.80
RunMethod · 0.65
ReadFileMethod · 0.65
NewMethod · 0.65
ContainsMethod · 0.45

Tested by

no test coverage detected