MCPcopy Create free account
hub / github.com/cli/cli / stubSkillByPath

Function stubSkillByPath

pkg/cmd/skills/install/install_test.go:251–260  ·  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

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