MCPcopy Index your code
hub / github.com/cli/cli / TestRecordInstall

Function TestRecordInstall

internal/skills/lockfile/lockfile_test.go:23–216  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

21}
22
23func TestRecordInstall(t *testing.T) {
24 tests := []struct {
25 name string
26 setup func(t *testing.T)
27 host string
28 skill string
29 owner string
30 repo string
31 skillPath string
32 treeSHA string
33 pinnedRef string
34 wantErr bool
35 verify func(t *testing.T, lockPath string)
36 }{
37 {
38 name: "fresh install creates lockfile",
39 host: "github.com",
40 skill: "code-review",
41 owner: "monalisa",
42 repo: "octocat-skills",
43 skillPath: "skills/code-review/SKILL.md",
44 treeSHA: "abc123",
45 verify: func(t *testing.T, lockPath string) {
46 t.Helper()
47 f := readTestLockfile(t, lockPath)
48 require.Contains(t, f.Skills, "code-review")
49 e := f.Skills["code-review"]
50 assert.Equal(t, "monalisa/octocat-skills", e.Source)
51 assert.Equal(t, "github", e.SourceType)
52 assert.Equal(t, "https://github.com/monalisa/octocat-skills.git", e.SourceURL)
53 assert.Equal(t, "skills/code-review/SKILL.md", e.SkillPath)
54 assert.Equal(t, "abc123", e.SkillFolderHash)
55 assert.NotEmpty(t, e.InstalledAt)
56 assert.NotEmpty(t, e.UpdatedAt)
57 assert.Empty(t, e.PinnedRef)
58 },
59 },
60 {
61 name: "tenancy host uses correct URL",
62 host: "mycompany.ghe.com",
63 skill: "code-review",
64 owner: "monalisa",
65 repo: "octocat-skills",
66 skillPath: "skills/code-review/SKILL.md",
67 treeSHA: "abc123",
68 verify: func(t *testing.T, lockPath string) {
69 t.Helper()
70 f := readTestLockfile(t, lockPath)
71 require.Contains(t, f.Skills, "code-review")
72 e := f.Skills["code-review"]
73 assert.Equal(t, "https://mycompany.ghe.com/monalisa/octocat-skills.git", e.SourceURL)
74 },
75 },
76 {
77 name: "install with pinned ref",
78 host: "github.com",
79 skill: "pr-summary",
80 owner: "hubot",

Callers

nothing calls this directly

Calls 11

TryLockFunction · 0.92
readTestLockfileFunction · 0.85
RecordInstallFunction · 0.85
lockfilePathFunction · 0.85
setupTestHomeFunction · 0.85
ContainsMethod · 0.80
EqualMethod · 0.80
verifyMethod · 0.80
HelperMethod · 0.65
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected