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

Function TestInstallRun_UpstreamDetection

pkg/cmd/skills/install/install_test.go:2757–2945  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2755}
2756
2757func TestInstallRun_UpstreamDetection(t *testing.T) {
2758 tests := []struct {
2759 name string
2760 isTTY bool
2761 stubs func(*httpmock.Registry)
2762 opts func(t *testing.T, ios *iostreams.IOStreams, reg *httpmock.Registry) *InstallOptions
2763 wantErr string
2764 wantStdout string
2765 wantStderr string
2766 }{
2767 {
2768 name: "detects re-published skill and user picks re-publisher",
2769 isTTY: true,
2770 stubs: func(reg *httpmock.Registry) {
2771 stubResolveVersion(reg, "monalisa", "skills-repo", "v1.0.0", "abc123")
2772 stubDiscoverTree(reg, "monalisa", "skills-repo", "abc123",
2773 singleSkillTreeJSON("git-commit", "treeSHA", "blobSHA"))
2774 stubContentsAPI(reg, "monalisa", "skills-repo",
2775 "skills/git-commit/SKILL.md", republishedContent)
2776 stubInstallFiles(reg, "monalisa", "skills-repo",
2777 "treeSHA", "blobSHA", republishedContent)
2778 },
2779 opts: func(t *testing.T, ios *iostreams.IOStreams, reg *httpmock.Registry) *InstallOptions {
2780 return &InstallOptions{
2781 IO: ios,
2782 HttpClient: func() (*http.Client, error) { return &http.Client{Transport: reg}, nil },
2783 GitClient: &git.Client{RepoDir: t.TempDir()},
2784 Prompter: &prompter.PrompterMock{
2785 SelectFunc: func(_ string, _ string, choices []string) (int, error) {
2786 require.Len(t, choices, 2)
2787 assert.Contains(t, choices[0], "monalisa/skills-repo")
2788 assert.Contains(t, choices[1], "monalisa/original-skills")
2789 return 0, nil
2790 },
2791 },
2792 Telemetry: &telemetry.NoOpService{},
2793 SkillSource: "monalisa/skills-repo",
2794 SkillName: "git-commit",
2795 Agent: "github-copilot",
2796 Scope: "project",
2797 ScopeChanged: true,
2798 Dir: t.TempDir(),
2799 }
2800 },
2801 wantStderr: "originally published in monalisa/original-skills",
2802 wantStdout: "Installed git-commit",
2803 },
2804 {
2805 name: "detects re-published skill and user picks upstream",
2806 isTTY: true,
2807 stubs: func(reg *httpmock.Registry) {
2808 stubResolveVersion(reg, "monalisa", "skills-repo", "v1.0.0", "abc123")
2809 stubDiscoverTree(reg, "monalisa", "skills-repo", "abc123",
2810 singleSkillTreeJSON("git-commit", "treeSHA", "blobSHA"))
2811 stubContentsAPI(reg, "monalisa", "skills-repo",
2812 "skills/git-commit/SKILL.md", republishedContent)
2813 stubResolveVersion(reg, "monalisa", "original-skills", "v2.0.0", "upstream456")
2814 stubDiscoverTree(reg, "monalisa", "original-skills", "upstream456",

Callers

nothing calls this directly

Calls 15

VerifyMethod · 0.95
TestFunction · 0.92
stubResolveVersionFunction · 0.85
stubDiscoverTreeFunction · 0.85
singleSkillTreeJSONFunction · 0.85
stubContentsAPIFunction · 0.85
stubInstallFilesFunction · 0.85
installRunFunction · 0.85
ContainsMethod · 0.80
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80

Tested by

no test coverage detected