MCPcopy Index your code
hub / github.com/cli/cli / TestInstallRun_TelemetryMultipleSkills

Function TestInstallRun_TelemetryMultipleSkills

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

Source from the content-addressed store, hash-verified

2563}
2564
2565func TestInstallRun_TelemetryMultipleSkills(t *testing.T) {
2566 codeReviewContent := heredoc.Doc(`
2567 ---
2568 name: code-review
2569 description: Reviews code
2570 ---
2571 # Code Review
2572 `)
2573
2574 reg := &httpmock.Registry{}
2575 defer reg.Verify(t)
2576
2577 stubResolveVersion(reg, "monalisa", "octocat-skills", "v1.0.0", "abc123")
2578 treeJSON := `{"path": "skills/git-commit", "type": "tree", "sha": "treeGC"}, ` +
2579 `{"path": "skills/git-commit/SKILL.md", "type": "blob", "sha": "blobGC"}, ` +
2580 `{"path": "skills/code-review", "type": "tree", "sha": "treeCR"}, ` +
2581 `{"path": "skills/code-review/SKILL.md", "type": "blob", "sha": "blobCR"}`
2582 stubDiscoverTree(reg, "monalisa", "octocat-skills", "abc123", treeJSON)
2583
2584 // Blob stubs for FetchDescriptionsConcurrent during interactive selection
2585 encGC := base64.StdEncoding.EncodeToString([]byte(gitCommitContent))
2586 encCR := base64.StdEncoding.EncodeToString([]byte(codeReviewContent))
2587 reg.Register(
2588 httpmock.REST("GET", "repos/monalisa/octocat-skills/git/blobs/blobGC"),
2589 httpmock.StringResponse(fmt.Sprintf(`{"sha": "blobGC", "content": %q, "encoding": "base64"}`, encGC)))
2590 reg.Register(
2591 httpmock.REST("GET", "repos/monalisa/octocat-skills/git/blobs/blobCR"),
2592 httpmock.StringResponse(fmt.Sprintf(`{"sha": "blobCR", "content": %q, "encoding": "base64"}`, encCR)))
2593
2594 stubInstallFiles(reg, "monalisa", "octocat-skills", "treeGC", "blobGC", gitCommitContent)
2595 stubInstallFiles(reg, "monalisa", "octocat-skills", "treeCR", "blobCR", codeReviewContent)
2596
2597 reg.Register(
2598 httpmock.REST("GET", "repos/monalisa/octocat-skills"),
2599 httpmock.JSONResponse(map[string]interface{}{
2600 "visibility": "public",
2601 }),
2602 )
2603
2604 ios, _, _, _ := iostreams.Test()
2605 ios.SetStdoutTTY(true)
2606 ios.SetStdinTTY(true)
2607
2608 pm := &prompter.PrompterMock{
2609 MultiSelectWithSearchFunc: func(_, _ string, _, _ []string, _ func(string) prompter.MultiSelectSearchResult) ([]string, error) {
2610 return []string{allSkillsKey}, nil
2611 },
2612 }
2613
2614 recorder := &telemetry.EventRecorderSpy{}
2615
2616 err := installRun(&InstallOptions{
2617 IO: ios,
2618 HttpClient: func() (*http.Client, error) { return &http.Client{Transport: reg}, nil },
2619 GitClient: &git.Client{RepoDir: t.TempDir()},
2620 Prompter: pm,
2621 SkillSource: "monalisa/octocat-skills",
2622 Agent: "github-copilot",

Callers

nothing calls this directly

Calls 15

VerifyMethod · 0.95
RegisterMethod · 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
SetStdinTTYMethod · 0.80

Tested by

no test coverage detected