(t *testing.T)
| 2722 | } |
| 2723 | |
| 2724 | func TestInstallRun_UpstreamDetection(t *testing.T) { |
| 2725 | tests := []struct { |
| 2726 | name string |
| 2727 | isTTY bool |
| 2728 | stubs func(*httpmock.Registry) |
| 2729 | opts func(t *testing.T, ios *iostreams.IOStreams, reg *httpmock.Registry) *InstallOptions |
| 2730 | wantErr string |
| 2731 | wantStdout string |
| 2732 | wantStderr string |
| 2733 | }{ |
| 2734 | { |
| 2735 | name: "detects re-published skill and user picks re-publisher", |
| 2736 | isTTY: true, |
| 2737 | stubs: func(reg *httpmock.Registry) { |
| 2738 | stubResolveVersion(reg, "monalisa", "skills-repo", "v1.0.0", "abc123") |
| 2739 | stubDiscoverTree(reg, "monalisa", "skills-repo", "abc123", |
| 2740 | singleSkillTreeJSON("git-commit", "treeSHA", "blobSHA")) |
| 2741 | stubContentsAPI(reg, "monalisa", "skills-repo", |
| 2742 | "skills/git-commit/SKILL.md", republishedContent) |
| 2743 | stubInstallFiles(reg, "monalisa", "skills-repo", |
| 2744 | "treeSHA", "blobSHA", republishedContent) |
| 2745 | }, |
| 2746 | opts: func(t *testing.T, ios *iostreams.IOStreams, reg *httpmock.Registry) *InstallOptions { |
| 2747 | return &InstallOptions{ |
| 2748 | IO: ios, |
| 2749 | HttpClient: func() (*http.Client, error) { return &http.Client{Transport: reg}, nil }, |
| 2750 | GitClient: &git.Client{RepoDir: t.TempDir()}, |
| 2751 | Prompter: &prompter.PrompterMock{ |
| 2752 | SelectFunc: func(_ string, _ string, choices []string) (int, error) { |
| 2753 | require.Len(t, choices, 2) |
| 2754 | assert.Contains(t, choices[0], "monalisa/skills-repo") |
| 2755 | assert.Contains(t, choices[1], "monalisa/original-skills") |
| 2756 | return 0, nil |
| 2757 | }, |
| 2758 | }, |
| 2759 | Telemetry: &telemetry.NoOpService{}, |
| 2760 | SkillSource: "monalisa/skills-repo", |
| 2761 | SkillName: "git-commit", |
| 2762 | Agent: "github-copilot", |
| 2763 | Scope: "project", |
| 2764 | ScopeChanged: true, |
| 2765 | Dir: t.TempDir(), |
| 2766 | } |
| 2767 | }, |
| 2768 | wantStderr: "originally published in monalisa/original-skills", |
| 2769 | wantStdout: "Installed git-commit", |
| 2770 | }, |
| 2771 | { |
| 2772 | name: "detects re-published skill and user picks upstream", |
| 2773 | isTTY: true, |
| 2774 | stubs: func(reg *httpmock.Registry) { |
| 2775 | stubResolveVersion(reg, "monalisa", "skills-repo", "v1.0.0", "abc123") |
| 2776 | stubDiscoverTree(reg, "monalisa", "skills-repo", "abc123", |
| 2777 | singleSkillTreeJSON("git-commit", "treeSHA", "blobSHA")) |
| 2778 | stubContentsAPI(reg, "monalisa", "skills-repo", |
| 2779 | "skills/git-commit/SKILL.md", republishedContent) |
| 2780 | stubResolveVersion(reg, "monalisa", "original-skills", "v2.0.0", "upstream456") |
| 2781 | stubDiscoverTree(reg, "monalisa", "original-skills", "upstream456", |
nothing calls this directly
no test coverage detected