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

Function TestScanInstalledSkills

pkg/cmd/skills/update/update_test.go:75–222  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

73}
74
75func TestScanInstalledSkills(t *testing.T) {
76 tests := []struct {
77 name string
78 setup func(t *testing.T, dir string)
79 verify func(t *testing.T, skills []installedSkill, err error)
80 }{
81 {
82 name: "happy path with metadata, no metadata, and pinned skills",
83 setup: func(t *testing.T, dir string) {
84 t.Helper()
85
86 // Skill with full metadata
87 skillDir := filepath.Join(dir, "git-commit")
88 require.NoError(t, os.MkdirAll(skillDir, 0o755))
89 content := heredoc.Doc(`
90 ---
91 name: git-commit
92 description: Git commit helper
93 metadata:
94 github-repo: https://github.com/monalisa/awesome-copilot
95 github-tree-sha: abc123
96 github-path: skills/git-commit
97 ---
98 Body content
99 `)
100 require.NoError(t, os.WriteFile(filepath.Join(skillDir, "SKILL.md"), []byte(content), 0o644))
101
102 // Skill without metadata
103 noMetaDir := filepath.Join(dir, "unknown-skill")
104 require.NoError(t, os.MkdirAll(noMetaDir, 0o755))
105 require.NoError(t, os.WriteFile(filepath.Join(noMetaDir, "SKILL.md"), []byte(heredoc.Doc(`
106 ---
107 name: unknown-skill
108 ---
109 No metadata here
110 `)), 0o644))
111
112 // Pinned skill
113 pinnedDir := filepath.Join(dir, "pinned-skill")
114 require.NoError(t, os.MkdirAll(pinnedDir, 0o755))
115 require.NoError(t, os.WriteFile(filepath.Join(pinnedDir, "SKILL.md"), []byte(heredoc.Doc(`
116 ---
117 name: pinned-skill
118 metadata:
119 github-repo: https://github.com/octocat/hubot-skills
120 github-tree-sha: def456
121 github-pinned: v1.0.0
122 ---
123 Pinned content
124 `)), 0o644))
125 },
126 verify: func(t *testing.T, skills []installedSkill, err error) {
127 t.Helper()
128 require.NoError(t, err)
129 assert.Len(t, skills, 3)
130
131 byName := make(map[string]installedSkill)
132 for _, s := range skills {

Callers

nothing calls this directly

Calls 10

JoinMethod · 0.80
EqualMethod · 0.80
EmptyMethod · 0.80
ContainsMethod · 0.80
verifyMethod · 0.80
scanInstalledSkillsFunction · 0.70
HelperMethod · 0.65
LenMethod · 0.65
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected