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

Function TestInstallRun_TelemetryMultipleSkills

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

Source from the content-addressed store, hash-verified

2790}
2791
2792func TestInstallRun_TelemetryMultipleSkills(t *testing.T) {
2793 codeReviewContent := heredoc.Doc(`
2794 ---
2795 name: code-review
2796 description: Reviews code
2797 ---
2798 # Code Review
2799 `)
2800
2801 reg := &httpmock.Registry{}
2802 defer reg.Verify(t)
2803
2804 stubRepository(reg, "monalisa", "octocat-skills", httpmock.JSONResponse(map[string]any{
2805 "id": 1,
2806 "visibility": "public",
2807 }))
2808 stubResolveLatestTag(reg, "monalisa", "octocat-skills", "v1.0.0", "abc123")
2809 treeJSON := `{"path": "skills/git-commit", "type": "tree", "sha": "treeGC"}, ` +
2810 `{"path": "skills/git-commit/SKILL.md", "type": "blob", "sha": "blobGC"}, ` +
2811 `{"path": "skills/code-review", "type": "tree", "sha": "treeCR"}, ` +
2812 `{"path": "skills/code-review/SKILL.md", "type": "blob", "sha": "blobCR"}`
2813 stubDiscoverTree(reg, "monalisa", "octocat-skills", "abc123", treeJSON)
2814
2815 // Blob stubs for FetchDescriptionsConcurrent during interactive selection
2816 encGC := base64.StdEncoding.EncodeToString([]byte(gitCommitContent))
2817 encCR := base64.StdEncoding.EncodeToString([]byte(codeReviewContent))
2818 reg.Register(
2819 httpmock.REST("GET", "repos/monalisa/octocat-skills/git/blobs/blobGC"),
2820 httpmock.StringResponse(fmt.Sprintf(`{"sha": "blobGC", "content": %q, "encoding": "base64"}`, encGC)))
2821 reg.Register(
2822 httpmock.REST("GET", "repos/monalisa/octocat-skills/git/blobs/blobCR"),
2823 httpmock.StringResponse(fmt.Sprintf(`{"sha": "blobCR", "content": %q, "encoding": "base64"}`, encCR)))
2824
2825 stubInstallFiles(reg, "monalisa", "octocat-skills", "treeGC", "blobGC", gitCommitContent)
2826 stubInstallFiles(reg, "monalisa", "octocat-skills", "treeCR", "blobCR", codeReviewContent)
2827
2828 ios, _, _, _ := iostreams.Test()
2829 ios.SetStdoutTTY(true)
2830 ios.SetStdinTTY(true)
2831
2832 pm := &prompter.PrompterMock{
2833 MultiSelectWithSearchFunc: func(_, _ string, _, _ []string, _ func(string) prompter.MultiSelectSearchResult) ([]string, error) {
2834 return []string{allSkillsKey}, nil
2835 },
2836 }
2837
2838 recorder := &telemetry.EventRecorderSpy{}
2839
2840 err := installRun(&InstallOptions{
2841 IO: ios,
2842 HttpClient: func() (*http.Client, error) { return &http.Client{Transport: reg}, nil },
2843 GitClient: &git.Client{RepoDir: t.TempDir()},
2844 Prompter: pm,
2845 SkillSource: "monalisa/octocat-skills",
2846 Agent: "github-copilot",
2847 Scope: "project",
2848 ScopeChanged: true,
2849 Dir: t.TempDir(),

Callers

nothing calls this directly

Calls 15

VerifyMethod · 0.95
RegisterMethod · 0.95
EventsMethod · 0.95
JSONResponseFunction · 0.92
RESTFunction · 0.92
StringResponseFunction · 0.92
TestFunction · 0.92
stubRepositoryFunction · 0.85
stubResolveLatestTagFunction · 0.85
stubDiscoverTreeFunction · 0.85
stubInstallFilesFunction · 0.85
installRunFunction · 0.85

Tested by

no test coverage detected