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

Function TestInstallRun_TelemetryMultipleSkills

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

Source from the content-addressed store, hash-verified

2713}
2714
2715func TestInstallRun_TelemetryMultipleSkills(t *testing.T) {
2716 codeReviewContent := heredoc.Doc(`
2717 ---
2718 name: code-review
2719 description: Reviews code
2720 ---
2721 # Code Review
2722 `)
2723
2724 reg := &httpmock.Registry{}
2725 defer reg.Verify(t)
2726
2727 stubResolveVersion(reg, "monalisa", "octocat-skills", "v1.0.0", "abc123")
2728 treeJSON := `{"path": "skills/git-commit", "type": "tree", "sha": "treeGC"}, ` +
2729 `{"path": "skills/git-commit/SKILL.md", "type": "blob", "sha": "blobGC"}, ` +
2730 `{"path": "skills/code-review", "type": "tree", "sha": "treeCR"}, ` +
2731 `{"path": "skills/code-review/SKILL.md", "type": "blob", "sha": "blobCR"}`
2732 stubDiscoverTree(reg, "monalisa", "octocat-skills", "abc123", treeJSON)
2733
2734 // Blob stubs for FetchDescriptionsConcurrent during interactive selection
2735 encGC := base64.StdEncoding.EncodeToString([]byte(gitCommitContent))
2736 encCR := base64.StdEncoding.EncodeToString([]byte(codeReviewContent))
2737 reg.Register(
2738 httpmock.REST("GET", "repos/monalisa/octocat-skills/git/blobs/blobGC"),
2739 httpmock.StringResponse(fmt.Sprintf(`{"sha": "blobGC", "content": %q, "encoding": "base64"}`, encGC)))
2740 reg.Register(
2741 httpmock.REST("GET", "repos/monalisa/octocat-skills/git/blobs/blobCR"),
2742 httpmock.StringResponse(fmt.Sprintf(`{"sha": "blobCR", "content": %q, "encoding": "base64"}`, encCR)))
2743
2744 stubInstallFiles(reg, "monalisa", "octocat-skills", "treeGC", "blobGC", gitCommitContent)
2745 stubInstallFiles(reg, "monalisa", "octocat-skills", "treeCR", "blobCR", codeReviewContent)
2746
2747 reg.Register(
2748 httpmock.REST("GET", "repos/monalisa/octocat-skills"),
2749 httpmock.JSONResponse(map[string]any{
2750 "visibility": "public",
2751 }),
2752 )
2753
2754 ios, _, _, _ := iostreams.Test()
2755 ios.SetStdoutTTY(true)
2756 ios.SetStdinTTY(true)
2757
2758 pm := &prompter.PrompterMock{
2759 MultiSelectWithSearchFunc: func(_, _ string, _, _ []string, _ func(string) prompter.MultiSelectSearchResult) ([]string, error) {
2760 return []string{allSkillsKey}, nil
2761 },
2762 }
2763
2764 recorder := &telemetry.EventRecorderSpy{}
2765
2766 err := installRun(&InstallOptions{
2767 IO: ios,
2768 HttpClient: func() (*http.Client, error) { return &http.Client{Transport: reg}, nil },
2769 GitClient: &git.Client{RepoDir: t.TempDir()},
2770 Prompter: pm,
2771 SkillSource: "monalisa/octocat-skills",
2772 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