(t *testing.T)
| 2879 | } |
| 2880 | |
| 2881 | func 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", |
nothing calls this directly
no test coverage detected