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

Function TestInstallRun_TelemetryVisibility

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

Source from the content-addressed store, hash-verified

2523}
2524
2525func TestInstallRun_TelemetryVisibility(t *testing.T) {
2526 tests := []struct {
2527 name string
2528 visibility string
2529 visibilityErr bool
2530 wantSkillNames string
2531 }{
2532 {
2533 name: "public repo includes skill names",
2534 visibility: "public",
2535 wantSkillNames: "git-commit",
2536 },
2537 {
2538 name: "private repo excludes skill names",
2539 visibility: "private",
2540 },
2541 {
2542 name: "internal repo excludes skill names",
2543 visibility: "internal",
2544 },
2545 {
2546 name: "API error omits visibility and skill names",
2547 visibilityErr: true,
2548 },
2549 }
2550
2551 for _, tt := range tests {
2552 t.Run(tt.name, func(t *testing.T) {
2553 reg := &httpmock.Registry{}
2554 defer reg.Verify(t)
2555
2556 stubResolveVersion(reg, "monalisa", "octocat-skills", "v1.0.0", "abc123")
2557 stubDiscoverTree(reg, "monalisa", "octocat-skills", "abc123",
2558 singleSkillTreeJSON("git-commit", "treeSHA", "blobSHA"))
2559 stubInstallFiles(reg, "monalisa", "octocat-skills", "treeSHA", "blobSHA", gitCommitContent)
2560 if tt.visibilityErr {
2561 reg.Register(
2562 httpmock.REST("GET", "repos/monalisa/octocat-skills"),
2563 httpmock.StatusStringResponse(500, "server error"),
2564 )
2565 } else {
2566 reg.Register(
2567 httpmock.REST("GET", "repos/monalisa/octocat-skills"),
2568 httpmock.JSONResponse(map[string]interface{}{
2569 "visibility": tt.visibility,
2570 }),
2571 )
2572 }
2573
2574 ios, _, _, _ := iostreams.Test()
2575 ios.SetStdoutTTY(true)
2576 ios.SetStdinTTY(true)
2577
2578 recorder := &telemetry.EventRecorderSpy{}
2579
2580 err := installRun(&InstallOptions{
2581 IO: ios,
2582 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