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