MCPcopy Index your code
hub / github.com/cli/cli / stubSkillByPath

Function stubSkillByPath

pkg/cmd/skills/install/install_test.go:250–259  ·  view source on GitHub ↗

stubSkillByPath registers stubs for DiscoverSkillByPath (contents API + tree).

(reg *httpmock.Registry, owner, repo, sha, skillPath, skillName, treeSHA string)

Source from the content-addressed store, hash-verified

248
249// stubSkillByPath registers stubs for DiscoverSkillByPath (contents API + tree).
250func stubSkillByPath(reg *httpmock.Registry, owner, repo, sha, skillPath, skillName, treeSHA string) {
251 parentPath := skillPath
252 if idx := strings.LastIndex(skillPath, "/"); idx >= 0 {
253 parentPath = skillPath[:idx]
254 }
255 reg.Register(
256 httpmock.REST("GET", fmt.Sprintf("repos/%s/%s/contents/%s", owner, repo, url.PathEscape(parentPath))),
257 httpmock.StringResponse(fmt.Sprintf(`[{"name": %q, "path": %q, "sha": %q, "type": "dir"}]`, skillName, skillPath, treeSHA)),
258 )
259}
260
261// writeLocalTestSkill creates a skill directory with a SKILL.md file.
262func writeLocalTestSkill(t *testing.T, baseDir, subPath, content string) {

Callers 1

TestInstallRunFunction · 0.85

Calls 3

RESTFunction · 0.92
StringResponseFunction · 0.92
RegisterMethod · 0.45

Tested by

no test coverage detected