From 26895da96918f9b1956a04981c8af5f3e42fcbd8 Mon Sep 17 00:00:00 2001 From: Michael Kelley Date: Sun, 23 Oct 2016 20:45:45 -0700 Subject: Implement tcell-based renderer --- src/history_test.go | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'src/history_test.go') diff --git a/src/history_test.go b/src/history_test.go index fa6f1066..0a014138 100644 --- a/src/history_test.go +++ b/src/history_test.go @@ -1,7 +1,10 @@ package fzf import ( + "io/ioutil" + "os" "os/user" + "runtime" "testing" ) @@ -10,23 +13,34 @@ func TestHistory(t *testing.T) { // Invalid arguments user, _ := user.Current() - paths := []string{"/etc", "/proc"} - if user.Name != "root" { - paths = append(paths, "/etc/sudoers") + var paths []string + if runtime.GOOS == "windows" { + // GOPATH should exist, so we shouldn't be able to override it + paths = []string{os.Getenv("GOPATH")} + } else { + paths = []string{"/etc", "/proc"} + if user.Name != "root" { + paths = append(paths, "/etc/sudoers") + } } + for _, path := range paths { if _, e := NewHistory(path, maxHistory); e == nil { t.Error("Error expected for: " + path) } } + + f, _ := ioutil.TempFile("", "fzf-history") + f.Close() + { // Append lines - h, _ := NewHistory("/tmp/fzf-history", maxHistory) + h, _ := NewHistory(f.Name(), maxHistory) for i := 0; i < maxHistory+10; i++ { h.append("foobar") } } { // Read lines - h, _ := NewHistory("/tmp/fzf-history", maxHistory) + h, _ := NewHistory(f.Name(), maxHistory) if len(h.lines) != maxHistory+1 { t.Errorf("Expected: %d, actual: %d\n", maxHistory+1, len(h.lines)) } @@ -37,13 +51,13 @@ func TestHistory(t *testing.T) { } } { // Append lines - h, _ := NewHistory("/tmp/fzf-history", maxHistory) + h, _ := NewHistory(f.Name(), maxHistory) h.append("barfoo") h.append("") h.append("foobarbaz") } { // Read lines again - h, _ := NewHistory("/tmp/fzf-history", maxHistory) + h, _ := NewHistory(f.Name(), maxHistory) if len(h.lines) != maxHistory+1 { t.Errorf("Expected: %d, actual: %d\n", maxHistory+1, len(h.lines)) } -- cgit v1.2.3