(t *testing.T)
| 2554 | } |
| 2555 | |
| 2556 | func 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 }, |
nothing calls this directly
no test coverage detected