github.com/elves/elvish@v0.15.0/pkg/cli/histutil/dedup_cursor_test.go (about) 1 package histutil 2 3 import ( 4 "testing" 5 6 "github.com/elves/elvish/pkg/store" 7 ) 8 9 func TestDedupCursor(t *testing.T) { 10 s := NewMemStore("0", "1", "2") 11 c := NewDedupCursor(s.Cursor("")) 12 13 wantCmds := []store.Cmd{ 14 {Text: "0", Seq: 0}, 15 {Text: "1", Seq: 1}, 16 {Text: "2", Seq: 2}} 17 18 testCursorIteration(t, c, wantCmds) 19 // Go back again, this time with a full stack 20 testCursorIteration(t, c, wantCmds) 21 22 c = NewDedupCursor(s.Cursor("")) 23 // Should be a no-op 24 c.Next() 25 testCursorIteration(t, c, wantCmds) 26 27 c = NewDedupCursor(s.Cursor("")) 28 c.Prev() 29 c.Next() 30 _, err := c.Get() 31 if err != ErrEndOfHistory { 32 t.Errorf("Get -> error %v, want ErrEndOfHistory", err) 33 } 34 }