diff options
Diffstat (limited to 'indexers/pikdex')
| -rw-r--r-- | indexers/pikdex/index.go | 25 | ||||
| -rw-r--r-- | indexers/pikdex/index_test.go | 9 |
2 files changed, 8 insertions, 26 deletions
diff --git a/indexers/pikdex/index.go b/indexers/pikdex/index.go index 64e76e6..70cfabb 100644 --- a/indexers/pikdex/index.go +++ b/indexers/pikdex/index.go @@ -3,6 +3,7 @@ package pikdex import ( "errors" "github.com/ewy1/pik/model" + "github.com/ewy1/pik/paths" "github.com/ewy1/pik/spool" "io/fs" "os" @@ -13,26 +14,6 @@ import ( "sync" ) -var Roots = []string{ - - // current name - ".pik", - "_pik", - - // program names from a previous life - ".godo", - "_godo", - ".pik", - "_uwu", - - //utility - ".bin", - "_bin", - "tasks", - ".tasks", - "_tasks", -} - var SkippedFolders = []string{ ".git", ".config", @@ -50,7 +31,7 @@ func (u *pikdex) Init() error { return nil } self = strings.TrimSuffix(self, ".exe") - Roots = append(Roots, "."+self, "_"+self) + paths.Roots = append(paths.Roots, "."+self, "_"+self) return nil } @@ -163,7 +144,7 @@ func (u *pikdex) WantsWalk(f fs.FS) (bool, string, error) { } for _, e := range entries { - for _, r := range Roots { + for _, r := range paths.Roots { if e.Name() == r && e.IsDir() { return true, r, nil } diff --git a/indexers/pikdex/index_test.go b/indexers/pikdex/index_test.go index c49d67f..8a82e55 100644 --- a/indexers/pikdex/index_test.go +++ b/indexers/pikdex/index_test.go @@ -1,6 +1,7 @@ package pikdex import ( + "github.com/ewy1/pik/paths" "github.com/stretchr/testify/assert" "io/fs" "testing" @@ -8,7 +9,7 @@ import ( ) func TestUwudex_WantsWalk_AnyRoot(t *testing.T) { - for _, r := range Roots { + for _, r := range paths.Roots { data := fstest.MapFS{ r: &fstest.MapFile{ Data: nil, @@ -25,11 +26,11 @@ func TestUwudex_WantsWalk_AnyRoot(t *testing.T) { func TestUwudex_WantsWalk_TwoRoots(t *testing.T) { data := fstest.MapFS{ - Roots[0]: &fstest.MapFile{ + paths.Roots[0]: &fstest.MapFile{ Data: nil, Mode: fs.ModeDir, }, - Roots[1]: &fstest.MapFile{ + paths.Roots[1]: &fstest.MapFile{ Data: nil, Mode: fs.ModeDir, }, @@ -37,7 +38,7 @@ func TestUwudex_WantsWalk_TwoRoots(t *testing.T) { u := &pikdex{} result, r, err := u.WantsWalk(data) // no guarantee we pick any one lol - assert.Contains(t, Roots, r) + assert.Contains(t, paths.Roots, r) assert.NoError(t, err) assert.True(t, result) } |
