MCPcopy
hub / github.com/cli/cli / TestDiscoverLocalSkillsWithOptions

Function TestDiscoverLocalSkillsWithOptions

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

Source from the content-addressed store, hash-verified

1448}
1449
1450func TestDiscoverLocalSkillsWithOptions(t *testing.T) {
1451 tests := []struct {
1452 name string
1453 setup func(t *testing.T, dir string)
1454 wantSkills []string
1455 wantErr string
1456 }{
1457 {
1458 name: "returns hidden dir skills",
1459 setup: func(t *testing.T, dir string) {
1460 t.Helper()
1461 skillDir := filepath.Join(dir, ".claude", "skills", "code-review")
1462 require.NoError(t, os.MkdirAll(skillDir, 0o755))
1463 require.NoError(t, os.WriteFile(filepath.Join(skillDir, "SKILL.md"), []byte("# code-review"), 0o644))
1464 },
1465 wantSkills: []string{"code-review"},
1466 },
1467 {
1468 name: "mixed standard and hidden returns all",
1469 setup: func(t *testing.T, dir string) {
1470 t.Helper()
1471 for _, p := range []string{"skills/standard", ".agents/skills/hidden"} {
1472 skillDir := filepath.Join(dir, filepath.FromSlash(p))
1473 require.NoError(t, os.MkdirAll(skillDir, 0o755))
1474 name := filepath.Base(p)
1475 require.NoError(t, os.WriteFile(filepath.Join(skillDir, "SKILL.md"), []byte("# "+name), 0o644))
1476 }
1477 },
1478 wantSkills: []string{"standard", "hidden"},
1479 },
1480 {
1481 name: "nested hidden dir returns skill",
1482 setup: func(t *testing.T, dir string) {
1483 t.Helper()
1484 skillDir := filepath.Join(dir, "foo", "bar", ".claude", "skills", "hidden")
1485 require.NoError(t, os.MkdirAll(skillDir, 0o755))
1486 require.NoError(t, os.WriteFile(filepath.Join(skillDir, "SKILL.md"), []byte("# hidden"), 0o644))
1487
1488 deepDir := filepath.Join(dir, "foo", "bar", ".claude", "nested", "skills", "deep-hidden")
1489 require.NoError(t, os.MkdirAll(deepDir, 0o755))
1490 require.NoError(t, os.WriteFile(filepath.Join(deepDir, "SKILL.md"), []byte("# deep-hidden"), 0o644))
1491 },
1492 wantSkills: []string{"deep-hidden", "hidden"},
1493 },
1494 {
1495 name: "no skills at all",
1496 setup: func(t *testing.T, _ string) { t.Helper() },
1497 wantErr: "no skills found",
1498 },
1499 }
1500 for _, tt := range tests {
1501 t.Run(tt.name, func(t *testing.T) {
1502 dir := filepath.Join(t.TempDir(), "repo")
1503 require.NoError(t, os.MkdirAll(dir, 0o755))
1504 tt.setup(t, dir)
1505
1506 skills, err := DiscoverLocalSkillsWithOptions(dir, DiscoverOptions{})
1507 if tt.wantErr != "" {

Callers

nothing calls this directly

Calls 7

JoinMethod · 0.80
BaseMethod · 0.80
ContainsMethod · 0.80
HelperMethod · 0.65
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected