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

Function TestInstallRun_UpstreamDetection

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

Source from the content-addressed store, hash-verified

2811}
2812
2813func TestInstallRun_UpstreamDetection(t *testing.T) {
2814 tests := []struct {
2815 name string
2816 isTTY bool
2817 stubs func(*httpmock.Registry)
2818 opts func(t *testing.T, ios *iostreams.IOStreams, reg *httpmock.Registry) *InstallOptions
2819 wantErr string
2820 wantStdout string
2821 wantStderr string
2822 }{
2823 {
2824 name: "detects re-published skill and user picks re-publisher",
2825 isTTY: true,
2826 stubs: func(reg *httpmock.Registry) {
2827 stubResolveVersion(reg, "monalisa", "skills-repo", "v1.0.0", "abc123")
2828 stubDiscoverTree(reg, "monalisa", "skills-repo", "abc123",
2829 singleSkillTreeJSON("git-commit", "treeSHA", "blobSHA"))
2830 stubContentsAPI(reg, "monalisa", "skills-repo",
2831 "skills/git-commit/SKILL.md", republishedContent)
2832 stubInstallFiles(reg, "monalisa", "skills-repo",
2833 "treeSHA", "blobSHA", republishedContent)
2834 },
2835 opts: func(t *testing.T, ios *iostreams.IOStreams, reg *httpmock.Registry) *InstallOptions {
2836 return &InstallOptions{
2837 IO: ios,
2838 HttpClient: func() (*http.Client, error) { return &http.Client{Transport: reg}, nil },
2839 GitClient: &git.Client{RepoDir: t.TempDir()},
2840 Prompter: &prompter.PrompterMock{
2841 SelectFunc: func(_ string, _ string, choices []string) (int, error) {
2842 require.Len(t, choices, 2)
2843 assert.Contains(t, choices[0], "monalisa/skills-repo")
2844 assert.Contains(t, choices[1], "monalisa/original-skills")
2845 return 0, nil
2846 },
2847 },
2848 Telemetry: &telemetry.NoOpService{},
2849 SkillSource: "monalisa/skills-repo",
2850 SkillName: "git-commit",
2851 Agent: "github-copilot",
2852 Scope: "project",
2853 ScopeChanged: true,
2854 Dir: t.TempDir(),
2855 }
2856 },
2857 wantStderr: "originally published in monalisa/original-skills",
2858 wantStdout: "Installed git-commit",
2859 },
2860 {
2861 name: "detects re-published skill and user picks upstream",
2862 isTTY: true,
2863 stubs: func(reg *httpmock.Registry) {
2864 stubResolveVersion(reg, "monalisa", "skills-repo", "v1.0.0", "abc123")
2865 stubDiscoverTree(reg, "monalisa", "skills-repo", "abc123",
2866 singleSkillTreeJSON("git-commit", "treeSHA", "blobSHA"))
2867 stubContentsAPI(reg, "monalisa", "skills-repo",
2868 "skills/git-commit/SKILL.md", republishedContent)
2869 stubResolveVersion(reg, "monalisa", "original-skills", "v2.0.0", "upstream456")
2870 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