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

Function TestInstallRun_TelemetryVisibility

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

Source from the content-addressed store, hash-verified

2610}
2611
2612func TestInstallRun_TelemetryVisibility(t *testing.T) {
2613 tests := []struct {
2614 name string
2615 visibility string
2616 visibilityErr bool
2617 wantSkillNames string
2618 }{
2619 {
2620 name: "public repo includes skill names",
2621 visibility: "public",
2622 wantSkillNames: "git-commit",
2623 },
2624 {
2625 name: "private repo excludes skill names",
2626 visibility: "private",
2627 },
2628 {
2629 name: "internal repo excludes skill names",
2630 visibility: "internal",
2631 },
2632 {
2633 name: "API error omits visibility and skill names",
2634 visibilityErr: true,
2635 },
2636 }
2637
2638 for _, tt := range tests {
2639 t.Run(tt.name, func(t *testing.T) {
2640 reg := &httpmock.Registry{}
2641 defer reg.Verify(t)
2642
2643 stubResolveVersion(reg, "monalisa", "octocat-skills", "v1.0.0", "abc123")
2644 stubDiscoverTree(reg, "monalisa", "octocat-skills", "abc123",
2645 singleSkillTreeJSON("git-commit", "treeSHA", "blobSHA"))
2646 stubInstallFiles(reg, "monalisa", "octocat-skills", "treeSHA", "blobSHA", gitCommitContent)
2647 if tt.visibilityErr {
2648 reg.Register(
2649 httpmock.REST("GET", "repos/monalisa/octocat-skills"),
2650 httpmock.StatusStringResponse(500, "server error"),
2651 )
2652 } else {
2653 reg.Register(
2654 httpmock.REST("GET", "repos/monalisa/octocat-skills"),
2655 httpmock.JSONResponse(map[string]any{
2656 "visibility": tt.visibility,
2657 }),
2658 )
2659 }
2660
2661 ios, _, _, _ := iostreams.Test()
2662 ios.SetStdoutTTY(true)
2663 ios.SetStdinTTY(true)
2664
2665 recorder := &telemetry.EventRecorderSpy{}
2666
2667 err := installRun(&InstallOptions{
2668 IO: ios,
2669 HttpClient: func() (*http.Client, error) { return &http.Client{Transport: reg}, nil },

Callers

nothing calls this directly

Calls 15

VerifyMethod · 0.95
RegisterMethod · 0.95
EventsMethod · 0.95
RESTFunction · 0.92
StatusStringResponseFunction · 0.92
JSONResponseFunction · 0.92
TestFunction · 0.92
stubResolveVersionFunction · 0.85
stubDiscoverTreeFunction · 0.85
singleSkillTreeJSONFunction · 0.85
stubInstallFilesFunction · 0.85
installRunFunction · 0.85

Tested by

no test coverage detected