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

Function TestInstallRun_TelemetryMultipleSkills

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

Source from the content-addressed store, hash-verified

2657}
2658
2659func TestInstallRun_TelemetryMultipleSkills(t *testing.T) {
2660 codeReviewContent := heredoc.Doc(`
2661 ---
2662 name: code-review
2663 description: Reviews code
2664 ---
2665 # Code Review
2666 `)
2667
2668 reg := &httpmock.Registry{}
2669 defer reg.Verify(t)
2670
2671 stubResolveVersion(reg, "monalisa", "octocat-skills", "v1.0.0", "abc123")
2672 treeJSON := `{"path": "skills/git-commit", "type": "tree", "sha": "treeGC"}, ` +
2673 `{"path": "skills/git-commit/SKILL.md", "type": "blob", "sha": "blobGC"}, ` +
2674 `{"path": "skills/code-review", "type": "tree", "sha": "treeCR"}, ` +
2675 `{"path": "skills/code-review/SKILL.md", "type": "blob", "sha": "blobCR"}`
2676 stubDiscoverTree(reg, "monalisa", "octocat-skills", "abc123", treeJSON)
2677
2678 // Blob stubs for FetchDescriptionsConcurrent during interactive selection
2679 encGC := base64.StdEncoding.EncodeToString([]byte(gitCommitContent))
2680 encCR := base64.StdEncoding.EncodeToString([]byte(codeReviewContent))
2681 reg.Register(
2682 httpmock.REST("GET", "repos/monalisa/octocat-skills/git/blobs/blobGC"),
2683 httpmock.StringResponse(fmt.Sprintf(`{"sha": "blobGC", "content": %q, "encoding": "base64"}`, encGC)))
2684 reg.Register(
2685 httpmock.REST("GET", "repos/monalisa/octocat-skills/git/blobs/blobCR"),
2686 httpmock.StringResponse(fmt.Sprintf(`{"sha": "blobCR", "content": %q, "encoding": "base64"}`, encCR)))
2687
2688 stubInstallFiles(reg, "monalisa", "octocat-skills", "treeGC", "blobGC", gitCommitContent)
2689 stubInstallFiles(reg, "monalisa", "octocat-skills", "treeCR", "blobCR", codeReviewContent)
2690
2691 reg.Register(
2692 httpmock.REST("GET", "repos/monalisa/octocat-skills"),
2693 httpmock.JSONResponse(map[string]any{
2694 "visibility": "public",
2695 }),
2696 )
2697
2698 ios, _, _, _ := iostreams.Test()
2699 ios.SetStdoutTTY(true)
2700 ios.SetStdinTTY(true)
2701
2702 pm := &prompter.PrompterMock{
2703 MultiSelectWithSearchFunc: func(_, _ string, _, _ []string, _ func(string) prompter.MultiSelectSearchResult) ([]string, error) {
2704 return []string{allSkillsKey}, nil
2705 },
2706 }
2707
2708 recorder := &telemetry.EventRecorderSpy{}
2709
2710 err := installRun(&InstallOptions{
2711 IO: ios,
2712 HttpClient: func() (*http.Client, error) { return &http.Client{Transport: reg}, nil },
2713 GitClient: &git.Client{RepoDir: t.TempDir()},
2714 Prompter: pm,
2715 SkillSource: "monalisa/octocat-skills",
2716 Agent: "github-copilot",

Callers

nothing calls this directly

Calls 15

VerifyMethod · 0.95
RegisterMethod · 0.95
EventsMethod · 0.95
RESTFunction · 0.92
StringResponseFunction · 0.92
JSONResponseFunction · 0.92
TestFunction · 0.92
stubResolveVersionFunction · 0.85
stubDiscoverTreeFunction · 0.85
stubInstallFilesFunction · 0.85
installRunFunction · 0.85
SetStdoutTTYMethod · 0.80

Tested by

no test coverage detected