github.com/ladydascalie/elvish@v0.0.0-20170703214355-2964dd3ece7f/store/dir_test.go (about) 1 package store 2 3 import ( 4 "reflect" 5 "testing" 6 7 "github.com/elves/elvish/store/storedefs" 8 ) 9 10 var ( 11 dirsToAdd = []string{"/usr/local", "/usr", "/usr/bin", "/usr"} 12 black = map[string]struct{}{"/usr/local": {}} 13 wantedDirs = []storedefs.Dir{ 14 {"/usr", scoreIncrement*scoreDecay*scoreDecay + scoreIncrement}, 15 {"/usr/bin", scoreIncrement * scoreDecay}} 16 ) 17 18 func TestDir(t *testing.T) { 19 for _, path := range dirsToAdd { 20 err := tStore.AddDir(path, 1) 21 if err != nil { 22 t.Errorf("tStore.AddDir(%q) => %v, want <nil>", path, err) 23 } 24 } 25 26 dirs, err := tStore.GetDirs(black) 27 if err != nil || !reflect.DeepEqual(dirs, wantedDirs) { 28 t.Errorf(`tStore.ListDirs() => (%v, %v), want (%v, <nil>)`, 29 dirs, err, wantedDirs) 30 } 31 }