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

Function TestPreviewRun_TelemetryVisibility

pkg/cmd/skills/preview/preview_test.go:986–1119  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

984}
985
986func TestPreviewRun_TelemetryVisibility(t *testing.T) {
987 skillContent := heredoc.Doc(`
988 ---
989 name: my-skill
990 description: test
991 ---
992 # My Skill
993 Body.
994 `)
995 encodedContent := base64.StdEncoding.EncodeToString([]byte(skillContent))
996
997 tests := []struct {
998 name string
999 visibility string
1000 visibilityErr bool
1001 wantSkillNames string
1002 }{
1003 {
1004 name: "public repo includes skill names",
1005 visibility: "public",
1006 wantSkillNames: "my-skill",
1007 },
1008 {
1009 name: "private repo excludes skill names",
1010 visibility: "private",
1011 },
1012 {
1013 name: "internal repo excludes skill names",
1014 visibility: "internal",
1015 },
1016 {
1017 name: "API error omits visibility and skill names",
1018 visibilityErr: true,
1019 },
1020 }
1021
1022 for _, tt := range tests {
1023 t.Run(tt.name, func(t *testing.T) {
1024 reg := &httpmock.Registry{}
1025 defer reg.Verify(t)
1026
1027 reg.Register(
1028 httpmock.REST("GET", "repos/owner/repo/releases/latest"),
1029 httpmock.StringResponse(`{"tag_name": "v1.0.0"}`),
1030 )
1031 reg.Register(
1032 httpmock.REST("GET", "repos/owner/repo/git/ref/tags%2Fv1.0.0"),
1033 httpmock.StringResponse(`{"object": {"sha": "abc123", "type": "commit"}}`),
1034 )
1035 reg.Register(
1036 httpmock.REST("GET", "repos/owner/repo/git/trees/abc123"),
1037 httpmock.StringResponse(`{
1038 "sha": "abc123",
1039 "truncated": false,
1040 "tree": [
1041 {"path": "skills/my-skill", "type": "tree", "sha": "treeSHA"},
1042 {"path": "skills/my-skill/SKILL.md", "type": "blob", "sha": "blobSKILL"}
1043 ]

Callers

nothing calls this directly

Calls 15

VerifyMethod · 0.95
RegisterMethod · 0.95
EventsMethod · 0.95
RESTFunction · 0.92
StringResponseFunction · 0.92
StatusStringResponseFunction · 0.92
JSONResponseFunction · 0.92
TestFunction · 0.92
NewFunction · 0.92
previewRunFunction · 0.85
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80

Tested by

no test coverage detected