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

Function TestPromptForSkillOrigin

pkg/cmd/skills/update/update_test.go:248–295  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

246}
247
248func TestPromptForSkillOrigin(t *testing.T) {
249 tests := []struct {
250 name string
251 input string
252 wantOK bool
253 wantOwner string
254 wantRepo string
255 wantReason string
256 }{
257 {
258 name: "valid owner/repo",
259 input: "monalisa/awesome-copilot",
260 wantOK: true,
261 wantOwner: "monalisa",
262 wantRepo: "awesome-copilot",
263 },
264 {
265 name: "empty input skips",
266 input: "",
267 wantOK: false,
268 },
269 {
270 name: "invalid format returns reason",
271 input: "just-a-name",
272 wantOK: false,
273 wantReason: "invalid repository",
274 },
275 }
276
277 for _, tt := range tests {
278 t.Run(tt.name, func(t *testing.T) {
279 pm := &prompter.PrompterMock{
280 InputFunc: func(prompt string, defaultValue string) (string, error) {
281 return tt.input, nil
282 },
283 }
284
285 owner, repo, reason, ok, err := promptForSkillOrigin(pm, "test-skill")
286 require.NoError(t, err)
287 assert.Equal(t, tt.wantOK, ok)
288 assert.Equal(t, tt.wantOwner, owner)
289 assert.Equal(t, tt.wantRepo, repo)
290 if tt.wantReason != "" {
291 assert.Contains(t, reason, tt.wantReason)
292 }
293 })
294 }
295}
296
297func TestScanAllAgentsDeduplicatesSharedProjectDirs(t *testing.T) {
298 repoDir := t.TempDir()

Callers

nothing calls this directly

Calls 4

promptForSkillOriginFunction · 0.85
EqualMethod · 0.80
ContainsMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected