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

Function TestInstallRun_TelemetryVisibility

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

Source from the content-addressed store, hash-verified

2554}
2555
2556func TestInstallRun_TelemetryVisibility(t *testing.T) {
2557 tests := []struct {
2558 name string
2559 visibility string
2560 visibilityErr bool
2561 wantSkillNames string
2562 }{
2563 {
2564 name: "public repo includes skill names",
2565 visibility: "public",
2566 wantSkillNames: "git-commit",
2567 },
2568 {
2569 name: "private repo excludes skill names",
2570 visibility: "private",
2571 },
2572 {
2573 name: "internal repo excludes skill names",
2574 visibility: "internal",
2575 },
2576 {
2577 name: "API error omits visibility and skill names",
2578 visibilityErr: true,
2579 },
2580 }
2581
2582 for _, tt := range tests {
2583 t.Run(tt.name, func(t *testing.T) {
2584 reg := &httpmock.Registry{}
2585 defer reg.Verify(t)
2586
2587 stubResolveVersion(reg, "monalisa", "octocat-skills", "v1.0.0", "abc123")
2588 stubDiscoverTree(reg, "monalisa", "octocat-skills", "abc123",
2589 singleSkillTreeJSON("git-commit", "treeSHA", "blobSHA"))
2590 stubInstallFiles(reg, "monalisa", "octocat-skills", "treeSHA", "blobSHA", gitCommitContent)
2591 if tt.visibilityErr {
2592 reg.Register(
2593 httpmock.REST("GET", "repos/monalisa/octocat-skills"),
2594 httpmock.StatusStringResponse(500, "server error"),
2595 )
2596 } else {
2597 reg.Register(
2598 httpmock.REST("GET", "repos/monalisa/octocat-skills"),
2599 httpmock.JSONResponse(map[string]any{
2600 "visibility": tt.visibility,
2601 }),
2602 )
2603 }
2604
2605 ios, _, _, _ := iostreams.Test()
2606 ios.SetStdoutTTY(true)
2607 ios.SetStdinTTY(true)
2608
2609 recorder := &telemetry.EventRecorderSpy{}
2610
2611 err := installRun(&InstallOptions{
2612 IO: ios,
2613 HttpClient: func() (*http.Client, error) { return &http.Client{Transport: reg}, nil },

Callers

nothing calls this directly

Calls 15

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

Tested by

no test coverage detected