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