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

Function TestInstallRun_UpstreamDetection

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

Source from the content-addressed store, hash-verified

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