MCPcopy
hub / github.com/cli/cli / TestDiscoverLocalSkills

Function TestDiscoverLocalSkills

internal/skills/discovery/discovery_test.go:1363–1448  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1361}
1362
1363func TestDiscoverLocalSkills(t *testing.T) {
1364 tests := []struct {
1365 name string
1366 createDir bool
1367 setup func(t *testing.T, dir string)
1368 wantSkills []string
1369 wantErr string
1370 }{
1371 {
1372 name: "discovers skills in skills/ directory",
1373 createDir: true,
1374 setup: func(t *testing.T, dir string) {
1375 t.Helper()
1376 for _, name := range []string{"code-review", "issue-triage"} {
1377 skillDir := filepath.Join(dir, "skills", name)
1378 require.NoError(t, os.MkdirAll(skillDir, 0o755))
1379 require.NoError(t, os.WriteFile(filepath.Join(skillDir, "SKILL.md"), []byte("# "+name), 0o644))
1380 }
1381 },
1382 wantSkills: []string{"code-review", "issue-triage"},
1383 },
1384 {
1385 name: "single skill at root",
1386 createDir: true,
1387 setup: func(t *testing.T, dir string) {
1388 t.Helper()
1389 require.NoError(t, os.WriteFile(filepath.Join(dir, "SKILL.md"), []byte(heredoc.Doc(`
1390 ---
1391 name: root-skill
1392 ---
1393 # Root
1394 `)), 0o644))
1395 },
1396 wantSkills: []string{"root-skill"},
1397 },
1398 {
1399 name: "no skills found",
1400 createDir: true,
1401 setup: func(t *testing.T, dir string) {
1402 t.Helper()
1403 require.NoError(t, os.WriteFile(filepath.Join(dir, "README.md"), []byte("# Not a skill"), 0o644))
1404 },
1405 wantErr: "no skills found",
1406 },
1407 {
1408 name: "nonexistent directory",
1409 setup: func(t *testing.T, dir string) {},
1410 wantErr: "could not access",
1411 },
1412 {
1413 name: "discovers skills in nested skills/ directory",
1414 createDir: true,
1415 setup: func(t *testing.T, dir string) {
1416 t.Helper()
1417 for _, name := range []string{"terraform-style-guide", "terraform-test"} {
1418 skillDir := filepath.Join(dir, "terraform", "code-generation", "skills", name)
1419 require.NoError(t, os.MkdirAll(skillDir, 0o755))
1420 require.NoError(t, os.WriteFile(filepath.Join(skillDir, "SKILL.md"), []byte("# "+name), 0o644))

Callers

nothing calls this directly

Calls 6

DiscoverLocalSkillsFunction · 0.85
JoinMethod · 0.80
ContainsMethod · 0.80
HelperMethod · 0.65
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected