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

Function TestInstallRun

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

Source from the content-addressed store, hash-verified

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