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

Function TestInstallRun_RepositoryID

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

Source from the content-addressed store, hash-verified

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