MCPcopy
hub / github.com/cli/cli / TestInstall

Function TestInstall

internal/skills/installer/installer_test.go:333–450  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

331}
332
333func TestInstall(t *testing.T) {
334 var progressCount atomic.Int32
335
336 tests := []struct {
337 name string
338 skills []discovery.Skill
339 stubs func(*httpmock.Registry)
340 onProgress func(done, total int)
341 wantInstalled []string
342 wantErr string
343 }{
344 {
345 name: "single skill calls OnProgress",
346 skills: []discovery.Skill{
347 {Name: "code-review", Path: "skills/code-review", TreeSHA: "tree-cr"},
348 },
349 stubs: func(reg *httpmock.Registry) { stubTreeAndBlob(reg, "tree-cr") },
350 onProgress: func(done, total int) {
351
352 progressCount.Add(1)
353
354 },
355 wantInstalled: []string{"code-review"},
356 },
357 {
358 name: "multiple skills concurrently with progress",
359 skills: []discovery.Skill{
360 {Name: "code-review", Path: "skills/code-review", TreeSHA: "tree-cr"},
361 {Name: "issue-triage", Path: "skills/issue-triage", TreeSHA: "tree-it"},
362 },
363 stubs: func(reg *httpmock.Registry) {
364 stubTreeAndBlob(reg, "tree-cr")
365 stubTreeAndBlob(reg, "tree-it")
366 },
367 onProgress: func(done, total int) {
368
369 progressCount.Add(1)
370
371 },
372 wantInstalled: []string{"code-review", "issue-triage"},
373 },
374 {
375 name: "partial failure returns successful installs and error",
376 skills: []discovery.Skill{
377 {Name: "code-review", Path: "skills/code-review", TreeSHA: "tree-cr"},
378 {Name: "issue-triage", Path: "skills/issue-triage", TreeSHA: "tree-fail"},
379 },
380 stubs: func(reg *httpmock.Registry) {
381 stubTreeAndBlob(reg, "tree-cr")
382 reg.Register(
383 httpmock.REST("GET", "repos/monalisa/octocat-skills/git/trees/tree-fail"),
384 httpmock.StatusStringResponse(500, "server error"))
385 },
386 wantInstalled: []string{"code-review"},
387 wantErr: "failed to install skill",
388 },
389 {
390 name: "no dir or agent host",

Callers

nothing calls this directly

Calls 13

RegisterMethod · 0.95
VerifyMethod · 0.95
RESTFunction · 0.92
StatusStringResponseFunction · 0.92
NewClientFromHTTPFunction · 0.92
stubTreeAndBlobFunction · 0.85
InstallFunction · 0.85
ContainsMethod · 0.80
EqualMethod · 0.80
JoinMethod · 0.80
AddMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected