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

Function TestInstallRun_UpstreamDetection

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

Source from the content-addressed store, hash-verified

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