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

Function TestInstallRun_TelemetryVisibility

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

Source from the content-addressed store, hash-verified

2461}
2462
2463func TestInstallRun_TelemetryVisibility(t *testing.T) {
2464 tests := []struct {
2465 name string
2466 visibility string
2467 visibilityErr bool
2468 wantSkillNames string
2469 }{
2470 {
2471 name: "public repo includes skill names",
2472 visibility: "public",
2473 wantSkillNames: "git-commit",
2474 },
2475 {
2476 name: "private repo excludes skill names",
2477 visibility: "private",
2478 },
2479 {
2480 name: "internal repo excludes skill names",
2481 visibility: "internal",
2482 },
2483 {
2484 name: "API error omits visibility and skill names",
2485 visibilityErr: true,
2486 },
2487 }
2488
2489 for _, tt := range tests {
2490 t.Run(tt.name, func(t *testing.T) {
2491 reg := &httpmock.Registry{}
2492 defer reg.Verify(t)
2493
2494 stubResolveVersion(reg, "monalisa", "octocat-skills", "v1.0.0", "abc123")
2495 stubDiscoverTree(reg, "monalisa", "octocat-skills", "abc123",
2496 singleSkillTreeJSON("git-commit", "treeSHA", "blobSHA"))
2497 stubInstallFiles(reg, "monalisa", "octocat-skills", "treeSHA", "blobSHA", gitCommitContent)
2498 if tt.visibilityErr {
2499 reg.Register(
2500 httpmock.REST("GET", "repos/monalisa/octocat-skills"),
2501 httpmock.StatusStringResponse(500, "server error"),
2502 )
2503 } else {
2504 reg.Register(
2505 httpmock.REST("GET", "repos/monalisa/octocat-skills"),
2506 httpmock.JSONResponse(map[string]interface{}{
2507 "visibility": tt.visibility,
2508 }),
2509 )
2510 }
2511
2512 ios, _, _, _ := iostreams.Test()
2513 ios.SetStdoutTTY(true)
2514 ios.SetStdinTTY(true)
2515
2516 recorder := &telemetry.EventRecorderSpy{}
2517
2518 err := installRun(&InstallOptions{
2519 IO: ios,
2520 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