@@ -0,0 +1,53 @@
8+ "github.com/stretchr/testify/require"
11+func TestLoadFromSource_NonExistentDir(t *testing.T) {
14+ dir := filepath.Join(t.TempDir(), "does-not-exist")
16+ cmds, err := loadFromSource(commandSource{path: dir, prefix: userCommandPrefix})
17+ require.NoError(t, err)
18+ require.Empty(t, cmds)
20+ // directory must NOT have been created
21+ _, statErr := os.Stat(dir)
22+ require.True(t, os.IsNotExist(statErr))
25+func TestLoadFromSource_ExistingDir(t *testing.T) {
29+ require.NoError(t, os.WriteFile(filepath.Join(dir, "hello.md"), []byte("say hello"), 0o644))
31+ cmds, err := loadFromSource(commandSource{path: dir, prefix: userCommandPrefix})
32+ require.NoError(t, err)
33+ require.Len(t, cmds, 1)
34+ require.Equal(t, "user:hello", cmds[0].ID)
35+ require.Equal(t, "say hello", cmds[0].Content)
38+func TestLoadAll_MixedSources(t *testing.T) {
41+ existing := t.TempDir()
42+ require.NoError(t, os.WriteFile(filepath.Join(existing, "cmd.md"), []byte("content"), 0o644))
44+ missing := filepath.Join(t.TempDir(), "nope")
46+ cmds, err := loadAll([]commandSource{
47+ {path: existing, prefix: userCommandPrefix},
48+ {path: missing, prefix: projectCommandPrefix},
50+ require.NoError(t, err)
51+ require.Len(t, cmds, 1)
52+ require.Equal(t, "user:cmd", cmds[0].ID)