MCPcopy
hub / github.com/cli/cli / TestInstallLocal

Function TestInstallLocal

internal/skills/installer/installer_test.go:21–183  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

19)
20
21func TestInstallLocal(t *testing.T) {
22 tests := []struct {
23 name string
24 skills []discovery.Skill
25 useAgentHost bool
26 setup func(t *testing.T, srcDir string)
27 verify func(t *testing.T, destDir string)
28 wantErr string
29 }{
30 {
31 name: "copies files via Dir",
32 skills: []discovery.Skill{{Name: "code-review", Path: "skills/code-review"}},
33 setup: func(t *testing.T, srcDir string) {
34 t.Helper()
35 skillSrc := filepath.Join(srcDir, "skills", "code-review")
36 require.NoError(t, os.MkdirAll(skillSrc, 0o755))
37 require.NoError(t, os.WriteFile(filepath.Join(skillSrc, "SKILL.md"), []byte("# Code Review"), 0o644))
38 require.NoError(t, os.WriteFile(filepath.Join(skillSrc, "prompt.txt"), []byte("review this PR"), 0o644))
39 },
40 verify: func(t *testing.T, destDir string) {
41 t.Helper()
42 content, err := os.ReadFile(filepath.Join(destDir, "code-review", "prompt.txt"))
43 require.NoError(t, err)
44 assert.Equal(t, "review this PR", string(content))
45
46 _, err = os.Stat(filepath.Join(destDir, "code-review", "SKILL.md"))
47 assert.NoError(t, err)
48 },
49 },
50 {
51 name: "nested directories",
52 skills: []discovery.Skill{{Name: "issue-triage", Path: "skills/issue-triage"}},
53 setup: func(t *testing.T, srcDir string) {
54 t.Helper()
55 deep := filepath.Join(srcDir, "skills", "issue-triage", "prompts", "templates")
56 require.NoError(t, os.MkdirAll(deep, 0o755))
57 require.NoError(t, os.WriteFile(filepath.Join(deep, "bug.txt"), []byte("triage bug"), 0o644))
58 require.NoError(t, os.WriteFile(
59 filepath.Join(srcDir, "skills", "issue-triage", "SKILL.md"), []byte("# Issue Triage"), 0o644))
60 },
61 verify: func(t *testing.T, destDir string) {
62 t.Helper()
63 content, err := os.ReadFile(filepath.Join(destDir, "issue-triage", "prompts", "templates", "bug.txt"))
64 require.NoError(t, err)
65 assert.Equal(t, "triage bug", string(content))
66 },
67 },
68 {
69 name: "skips symlinks",
70 skills: []discovery.Skill{{Name: "pr-summary", Path: "skills/pr-summary"}},
71 setup: func(t *testing.T, srcDir string) {
72 t.Helper()
73 skillSrc := filepath.Join(srcDir, "skills", "pr-summary")
74 require.NoError(t, os.MkdirAll(skillSrc, 0o755))
75 require.NoError(t, os.WriteFile(filepath.Join(skillSrc, "SKILL.md"), []byte("# PR Summary"), 0o644))
76 require.NoError(t, os.WriteFile(filepath.Join(skillSrc, "prompt.txt"), []byte("summarize"), 0o644))
77 require.NoError(t, os.Symlink(filepath.Join(skillSrc, "prompt.txt"), filepath.Join(skillSrc, "link.txt")))
78 },

Callers

nothing calls this directly

Calls 10

FindByIDFunction · 0.92
InstallLocalFunction · 0.85
JoinMethod · 0.80
EqualMethod · 0.80
ContainsMethod · 0.80
verifyMethod · 0.80
HelperMethod · 0.65
RunMethod · 0.65
LenMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected