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

Function TestInstallRun_RepositoryID

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

Source from the content-addressed store, hash-verified

1726}
1727
1728func TestInstallRun_RepositoryID(t *testing.T) {
1729 tests := []struct {
1730 name string
1731 repoResp httpmock.Responder
1732 wantErr string
1733 wantMeta string
1734 }{
1735 {
1736 name: "records the repository ID",
1737 repoResp: httpmock.StringResponse(`{"id": 1296269}`),
1738 wantMeta: `github-repo-id: "1296269"`,
1739 },
1740 {
1741 name: "fails when the repository can't be looked up",
1742 repoResp: httpmock.StatusStringResponse(500, "server error"),
1743 wantErr: "could not look up repository monalisa/skills-repo",
1744 },
1745 }
1746
1747 for _, tt := range tests {
1748 t.Run(tt.name, func(t *testing.T) {
1749 homeDir := t.TempDir()
1750 t.Setenv("HOME", homeDir)
1751 t.Setenv("USERPROFILE", homeDir)
1752
1753 reg := &httpmock.Registry{}
1754 defer reg.Verify(t)
1755
1756 stubRepository(reg, "monalisa", "skills-repo", tt.repoResp)
1757 stubResolveLatestTag(reg, "monalisa", "skills-repo", "v1.0.0", "abc123")
1758 if tt.wantErr == "" {
1759 stubDiscoverTree(reg, "monalisa", "skills-repo", "abc123",
1760 singleSkillTreeJSON("git-commit", "treeSHA", "blobSHA"))
1761 stubInstallFiles(reg, "monalisa", "skills-repo", "treeSHA", "blobSHA", gitCommitContent)
1762 }
1763
1764 ios, _, _, _ := iostreams.Test()
1765 targetDir := t.TempDir()
1766
1767 err := installRun(&InstallOptions{
1768 IO: ios,
1769 HttpClient: func() (*http.Client, error) { return &http.Client{Transport: reg}, nil },
1770 GitClient: &git.Client{RepoDir: t.TempDir()},
1771 SkillSource: "monalisa/skills-repo",
1772 SkillName: "git-commit",
1773 Force: true,
1774 Agent: "github-copilot",
1775 Scope: "project",
1776 ScopeChanged: true,
1777 Dir: targetDir,
1778 Telemetry: &telemetry.NoOpService{},
1779 })
1780 if tt.wantErr != "" {
1781 require.ErrorContains(t, err, tt.wantErr)
1782 assert.NoFileExists(t, filepath.Join(targetDir, "git-commit", "SKILL.md"))
1783 return
1784 }
1785 require.NoError(t, err)

Callers

nothing calls this directly

Calls 13

VerifyMethod · 0.95
StringResponseFunction · 0.92
StatusStringResponseFunction · 0.92
TestFunction · 0.92
stubRepositoryFunction · 0.85
stubResolveLatestTagFunction · 0.85
stubDiscoverTreeFunction · 0.85
singleSkillTreeJSONFunction · 0.85
stubInstallFilesFunction · 0.85
installRunFunction · 0.85
JoinMethod · 0.80
ContainsMethod · 0.80

Tested by

no test coverage detected