MCPcopy
hub / github.com/cli/cli / stubInstallFiles

Function stubInstallFiles

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

stubInstallFiles registers subtree + blob stubs for installer.Install (one skill).

(reg *httpmock.Registry, owner, repo, treeSHA, blobSHA, content string)

Source from the content-addressed store, hash-verified

235
236// stubInstallFiles registers subtree + blob stubs for installer.Install (one skill).
237func stubInstallFiles(reg *httpmock.Registry, owner, repo, treeSHA, blobSHA, content string) {
238 encoded := base64.StdEncoding.EncodeToString([]byte(content))
239 reg.Register(
240 httpmock.REST("GET", fmt.Sprintf("repos/%s/%s/git/trees/%s", owner, repo, treeSHA)),
241 httpmock.StringResponse(fmt.Sprintf(`{"tree": [{"path": "SKILL.md", "type": "blob", "sha": %q, "size": 50}]}`, blobSHA)),
242 )
243 reg.Register(
244 httpmock.REST("GET", fmt.Sprintf("repos/%s/%s/git/blobs/%s", owner, repo, blobSHA)),
245 httpmock.StringResponse(fmt.Sprintf(`{"sha": %q, "content": %q, "encoding": "base64"}`, blobSHA, encoded)),
246 )
247}
248
249// stubSkillByPath registers stubs for DiscoverSkillByPath (contents API + tree).
250func stubSkillByPath(reg *httpmock.Registry, owner, repo, sha, skillPath, skillName, treeSHA string) {

Calls 3

RESTFunction · 0.92
StringResponseFunction · 0.92
RegisterMethod · 0.45

Tested by

no test coverage detected