MCPcopy
hub / github.com/cli/cli / TestPreviewRun

Function TestPreviewRun

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

Source from the content-addressed store, hash-verified

110}
111
112func TestPreviewRun(t *testing.T) {
113 skillContent := heredoc.Doc(`
114 ---
115 name: my-skill
116 description: A test skill
117 ---
118 # My Skill
119
120 This is the skill content.
121 `)
122 encodedContent := base64.StdEncoding.EncodeToString([]byte(skillContent))
123
124 tests := []struct {
125 name string
126 opts *PreviewOptions
127 tty bool
128 httpStubs func(*httpmock.Registry)
129 wantStdout string
130 wantErr string
131 }{
132 {
133 name: "preview specific skill",
134 tty: true,
135 opts: &PreviewOptions{
136 repo: ghrepo.New("github", "awesome-copilot"),
137 SkillName: "my-skill",
138 },
139 httpStubs: func(reg *httpmock.Registry) {
140 reg.Register(
141 httpmock.REST("GET", "repos/github/awesome-copilot/releases/latest"),
142 httpmock.StringResponse(`{"tag_name": "v1.0.0"}`),
143 )
144 reg.Register(
145 httpmock.REST("GET", "repos/github/awesome-copilot/git/ref/tags/v1.0.0"),
146 httpmock.StringResponse(`{"object": {"sha": "abc123", "type": "commit"}}`),
147 )
148 reg.Register(
149 httpmock.REST("GET", "repos/github/awesome-copilot/git/trees/abc123"),
150 httpmock.StringResponse(`{
151 "sha": "abc123",
152 "truncated": false,
153 "tree": [
154 {"path": "skills", "type": "tree", "sha": "tree1"},
155 {"path": "skills/my-skill", "type": "tree", "sha": "treeSHA"},
156 {"path": "skills/my-skill/SKILL.md", "type": "blob", "sha": "blob123"}
157 ]
158 }`),
159 )
160 reg.Register(
161 httpmock.REST("GET", "repos/github/awesome-copilot/git/trees/treeSHA"),
162 httpmock.StringResponse(`{
163 "tree": [
164 {"path": "SKILL.md", "type": "blob", "sha": "blob123", "size": 50}
165 ]
166 }`),
167 )
168 reg.Register(
169 httpmock.REST("GET", "repos/github/awesome-copilot/git/blobs/blob123"),

Callers

nothing calls this directly

Calls 13

RegisterMethod · 0.95
VerifyMethod · 0.95
NewFunction · 0.92
RESTFunction · 0.92
StringResponseFunction · 0.92
StatusStringResponseFunction · 0.92
TestFunction · 0.92
previewRunFunction · 0.85
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
ContainsMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected