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

Function TestInstallRun

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

Source from the content-addressed store, hash-verified

320}
321
322func TestInstallRun(t *testing.T) {
323 tests := []struct {
324 name string
325 isTTY bool
326 setup func(t *testing.T)
327 stubs func(*httpmock.Registry)
328 opts func(ios *iostreams.IOStreams, reg *httpmock.Registry) *InstallOptions
329 verify func(t *testing.T)
330 wantErr string
331 wantStdout string
332 wantStderr string
333 assert func(t *testing.T)
334 }{
335 {
336 name: "non-interactive without repo errors",
337 isTTY: false,
338 opts: func(ios *iostreams.IOStreams, _ *httpmock.Registry) *InstallOptions {
339 t.Helper()
340 return &InstallOptions{
341 IO: ios,
342 GitClient: &git.Client{RepoDir: t.TempDir()},
343 }
344 },
345 wantErr: "must specify a repository to install from",
346 },
347 {
348 name: "non-interactive without skill name lists available skills",
349 isTTY: false,
350 stubs: func(reg *httpmock.Registry) {
351 stubResolveVersion(reg, "monalisa", "skills-repo", "v1.0.0", "abc123")
352 stubDiscoverTree(reg, "monalisa", "skills-repo", "abc123",
353 singleSkillTreeJSON("git-commit", "treeSHA", "blobSHA"))
354 encoded := base64.StdEncoding.EncodeToString([]byte(gitCommitContent))
355 reg.Register(
356 httpmock.REST("GET", "repos/monalisa/skills-repo/git/blobs/blobSHA"),
357 httpmock.StringResponse(fmt.Sprintf(`{"sha": "blobSHA", "content": %q, "encoding": "base64"}`, encoded)),
358 )
359 },
360 opts: func(ios *iostreams.IOStreams, reg *httpmock.Registry) *InstallOptions {
361 t.Helper()
362 return &InstallOptions{
363 IO: ios,
364 HttpClient: func() (*http.Client, error) { return &http.Client{Transport: reg}, nil },
365 GitClient: &git.Client{RepoDir: t.TempDir()},
366 SkillSource: "monalisa/skills-repo",
367 Agent: "github-copilot",
368 Scope: "project",
369 ScopeChanged: true,
370 }
371 },
372 wantStdout: "git-commit\tWrites commits\n",
373 },
374 {
375 name: "remote install writes files with tracking metadata",
376 isTTY: true,
377 stubs: func(reg *httpmock.Registry) {
378 stubResolveVersion(reg, "monalisa", "skills-repo", "v1.0.0", "abc123")
379 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
stubRepositoryFunction · 0.85

Tested by

no test coverage detected