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

Function TestInstallRun_UpstreamDetection

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

Source from the content-addressed store, hash-verified

2879}
2880
2881func TestInstallRun_UpstreamDetection(t *testing.T) {
2882 tests := []struct {
2883 name string
2884 isTTY bool
2885 stubs func(*httpmock.Registry)
2886 opts func(t *testing.T, ios *iostreams.IOStreams, reg *httpmock.Registry) *InstallOptions
2887 wantErr string
2888 wantStdout string
2889 wantStderr string
2890 }{
2891 {
2892 name: "detects re-published skill and user picks re-publisher",
2893 isTTY: true,
2894 stubs: func(reg *httpmock.Registry) {
2895 stubResolveVersion(reg, "monalisa", "skills-repo", "v1.0.0", "abc123")
2896 stubDiscoverTree(reg, "monalisa", "skills-repo", "abc123",
2897 singleSkillTreeJSON("git-commit", "treeSHA", "blobSHA"))
2898 stubContentsAPI(reg, "monalisa", "skills-repo",
2899 "skills/git-commit/SKILL.md", republishedContent)
2900 stubInstallFiles(reg, "monalisa", "skills-repo",
2901 "treeSHA", "blobSHA", republishedContent)
2902 },
2903 opts: func(t *testing.T, ios *iostreams.IOStreams, reg *httpmock.Registry) *InstallOptions {
2904 return &InstallOptions{
2905 IO: ios,
2906 HttpClient: func() (*http.Client, error) { return &http.Client{Transport: reg}, nil },
2907 GitClient: &git.Client{RepoDir: t.TempDir()},
2908 Prompter: &prompter.PrompterMock{
2909 SelectFunc: func(_ string, _ string, choices []string) (int, error) {
2910 require.Len(t, choices, 2)
2911 assert.Contains(t, choices[0], "monalisa/skills-repo")
2912 assert.Contains(t, choices[1], "monalisa/original-skills")
2913 return 0, nil
2914 },
2915 },
2916 Telemetry: &telemetry.NoOpService{},
2917 SkillSource: "monalisa/skills-repo",
2918 SkillName: "git-commit",
2919 Agent: "github-copilot",
2920 Scope: "project",
2921 ScopeChanged: true,
2922 Dir: t.TempDir(),
2923 }
2924 },
2925 wantStderr: "originally published in monalisa/original-skills",
2926 wantStdout: "Installed git-commit",
2927 },
2928 {
2929 name: "detects re-published skill and user picks upstream",
2930 isTTY: true,
2931 stubs: func(reg *httpmock.Registry) {
2932 stubResolveVersion(reg, "monalisa", "skills-repo", "v1.0.0", "abc123")
2933 stubDiscoverTree(reg, "monalisa", "skills-repo", "abc123",
2934 singleSkillTreeJSON("git-commit", "treeSHA", "blobSHA"))
2935 stubContentsAPI(reg, "monalisa", "skills-repo",
2936 "skills/git-commit/SKILL.md", republishedContent)
2937 stubResolveVersion(reg, "monalisa", "original-skills", "v2.0.0", "upstream456")
2938 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