github.com/hugelgupf/u-root@v0.0.0-20191023214958-4807c632154c/cmds/core/elvish/store/dir_test.go (about)

     1  package store
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/u-root/u-root/cmds/core/elvish/store/storedefs"
     7  )
     8  
     9  var (
    10  	dirsToAdd  = []string{"/usr/local", "/usr", "/usr/bin", "/usr"}
    11  	black      = map[string]struct{}{"/usr/local": {}}
    12  	wantedDirs = []storedefs.Dir{
    13  		{"/usr", scoreIncrement*scoreDecay*scoreDecay + scoreIncrement},
    14  		{"/usr/bin", scoreIncrement * scoreDecay}}
    15  	dirToDel           = "/usr"
    16  	wantedDirsAfterDel = []storedefs.Dir{
    17  		{"/usr/bin", scoreIncrement * scoreDecay}}
    18  )
    19  
    20  func testDir(t *testing.T) {
    21  	tStore := NewCmdHistory()
    22  	for _, path := range dirsToAdd {
    23  		_, err := tStore.Add(path) //, 1)
    24  		if err != nil {
    25  			t.Errorf("tStore.Add(%q) => %v, want <nil>", path, err)
    26  		}
    27  	}
    28  
    29  	/* The whole Store interface is a total clusterfuck. Fix later.
    30  	dirs, err := tStore.List(black)
    31  	if err != nil || !reflect.DeepEqual(dirs, wantedDirs) {
    32  		t.Errorf(`tStore.ListDirs() => (%v, %v), want (%v, <nil>)`,
    33  			dirs, err, wantedDirs)
    34  	}
    35  
    36  	tStore.DelDir("/usr")
    37  	dirs, err = tStore.List(black)
    38  	if err != nil || !reflect.DeepEqual(dirs, wantedDirsAfterDel) {
    39  		t.Errorf(`After DelDir("/usr"), tStore.ListDirs() => (%v, %v), want (%v, <nil>)`,
    40  			dirs, err, wantedDirsAfterDel)
    41  	}
    42  	*/
    43  }