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

Function TestInstallCommandArgs

pkg/cmd/skills/search/search_test.go:467–529  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

465}
466
467func TestInstallCommandArgs(t *testing.T) {
468 tests := []struct {
469 name string
470 resultPath string
471 wantSkill string
472 want []string
473 }{
474 {
475 name: "namespaced skill",
476 resultPath: "skills/monalisa/code-review/SKILL.md",
477 wantSkill: "skills/monalisa/code-review",
478 want: []string{
479 "skills", "install",
480 "--agent", "github-copilot",
481 "--scope", "project",
482 "--",
483 "org/repo", "skills/monalisa/code-review",
484 },
485 },
486 {
487 name: "flag-like result path",
488 resultPath: "--option/skills/monalisa/code-review/SKILL.md",
489 wantSkill: "--option/skills/monalisa/code-review",
490 want: []string{
491 "skills", "install",
492 "--agent", "github-copilot",
493 "--scope", "project",
494 "--",
495 "org/repo", "--option/skills/monalisa/code-review",
496 },
497 },
498 }
499
500 for _, tt := range tests {
501 t.Run(tt.name, func(t *testing.T) {
502 results := deduplicateResults([]codeSearchItem{{
503 Path: tt.resultPath,
504 Repository: codeSearchRepository{FullName: "org/repo"},
505 }})
506 require.Len(t, results, 1)
507
508 args := installCommandArgs(results[0], "github-copilot", "project")
509 assert.Equal(t, tt.want, args)
510
511 var installOpts *install.InstallOptions
512 cmd := install.NewCmdInstall(&cmdutil.Factory{}, &telemetry.NoOpService{}, func(opts *install.InstallOptions) error {
513 installOpts = opts
514 return nil
515 })
516 cmd.SetArgs(args[2:])
517 cmd.SetOut(io.Discard)
518 cmd.SetErr(io.Discard)
519
520 _, err := cmd.ExecuteC()
521 require.NoError(t, err)
522 require.NotNil(t, installOpts)
523 assert.Equal(t, "org/repo", installOpts.SkillSource)
524 assert.Equal(t, tt.wantSkill, installOpts.SkillName)

Callers

nothing calls this directly

Calls 6

NewCmdInstallFunction · 0.92
deduplicateResultsFunction · 0.85
installCommandArgsFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65
LenMethod · 0.65

Tested by

no test coverage detected