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

Function TestInstallRun

pkg/cmd/skills/install/install_test.go:304–1673  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

302}
303
304func TestInstallRun(t *testing.T) {
305 tests := []struct {
306 name string
307 isTTY bool
308 setup func(t *testing.T)
309 stubs func(*httpmock.Registry)
310 opts func(ios *iostreams.IOStreams, reg *httpmock.Registry) *InstallOptions
311 verify func(t *testing.T)
312 wantErr string
313 wantStdout string
314 wantStderr string
315 assert func(t *testing.T)
316 }{
317 {
318 name: "non-interactive without repo errors",
319 isTTY: false,
320 opts: func(ios *iostreams.IOStreams, _ *httpmock.Registry) *InstallOptions {
321 t.Helper()
322 return &InstallOptions{
323 IO: ios,
324 GitClient: &git.Client{RepoDir: t.TempDir()},
325 }
326 },
327 wantErr: "must specify a repository to install from",
328 },
329 {
330 name: "non-interactive without skill name lists available skills",
331 isTTY: false,
332 stubs: func(reg *httpmock.Registry) {
333 stubResolveVersion(reg, "monalisa", "skills-repo", "v1.0.0", "abc123")
334 stubDiscoverTree(reg, "monalisa", "skills-repo", "abc123",
335 singleSkillTreeJSON("git-commit", "treeSHA", "blobSHA"))
336 encoded := base64.StdEncoding.EncodeToString([]byte(gitCommitContent))
337 reg.Register(
338 httpmock.REST("GET", "repos/monalisa/skills-repo/git/blobs/blobSHA"),
339 httpmock.StringResponse(fmt.Sprintf(`{"sha": "blobSHA", "content": %q, "encoding": "base64"}`, encoded)),
340 )
341 },
342 opts: func(ios *iostreams.IOStreams, reg *httpmock.Registry) *InstallOptions {
343 t.Helper()
344 return &InstallOptions{
345 IO: ios,
346 HttpClient: func() (*http.Client, error) { return &http.Client{Transport: reg}, nil },
347 GitClient: &git.Client{RepoDir: t.TempDir()},
348 SkillSource: "monalisa/skills-repo",
349 Agent: "github-copilot",
350 Scope: "project",
351 ScopeChanged: true,
352 }
353 },
354 wantStdout: "git-commit\tWrites commits\n",
355 },
356 {
357 name: "remote install writes files with tracking metadata",
358 isTTY: true,
359 stubs: func(reg *httpmock.Registry) {
360 stubResolveVersion(reg, "monalisa", "skills-repo", "v1.0.0", "abc123")
361 stubDiscoverTree(reg, "monalisa", "skills-repo", "abc123",

Callers

nothing calls this directly

Calls 15

RegisterMethod · 0.95
VerifyMethod · 0.95
RESTFunction · 0.92
StringResponseFunction · 0.92
StatusStringResponseFunction · 0.92
NewFunction · 0.92
TestFunction · 0.92
stubResolveVersionFunction · 0.85
stubDiscoverTreeFunction · 0.85
singleSkillTreeJSONFunction · 0.85
stubInstallFilesFunction · 0.85
stubSkillByPathFunction · 0.85

Tested by

no test coverage detected