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

Function TestLoadSkillBody

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

Source from the content-addressed store, hash-verified

124}
125
126func TestLoadSkillBody(t *testing.T) {
127 t.Parallel()
128
129 t.Run("ReturnsBodyAndFiles", func(t *testing.T) {
130 t.Parallel()
131
132 ctrl := gomock.NewController(t)
133 conn := agentconnmock.NewMockAgentConn(ctrl)
134
135 skill := chattool.SkillMeta{
136 Name: "my-skill",
137 Description: "desc",
138 Dir: "/work/.agents/skills/my-skill",
139 }
140
141 // Read the full SKILL.md.
142 conn.EXPECT().ReadFile(
143 gomock.Any(),
144 "/work/.agents/skills/my-skill/SKILL.md",
145 int64(0),
146 int64(64*1024+1),
147 ).Return(
148 io.NopCloser(strings.NewReader(validSkillMD("my-skill", "desc"))),
149 "text/markdown",
150 nil,
151 )
152
153 // List supporting files.
154 conn.EXPECT().LS(gomock.Any(), "", gomock.Any()).Return(
155 workspacesdk.LSResponse{
156 Contents: []workspacesdk.LSFile{
157 {Name: "SKILL.md"},
158 {Name: "helper.md"},
159 {Name: "roles", IsDir: true},
160 },
161 }, nil,
162 )
163
164 content, err := chattool.LoadSkillBody(context.Background(), conn, skill, "SKILL.md")
165 require.NoError(t, err)
166 assert.Contains(t, content.Body, "Do the thing.")
167 assert.Equal(t, []string{"helper.md", "roles/"}, content.Files)
168 })
169}
170
171func TestLoadSkillFile(t *testing.T) {
172 t.Parallel()

Callers

nothing calls this directly

Calls 9

EXPECTMethod · 0.95
NewMockAgentConnFunction · 0.92
LoadSkillBodyFunction · 0.92
validSkillMDFunction · 0.85
RunMethod · 0.65
ReadFileMethod · 0.65
LSMethod · 0.65
ContainsMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected