summaryrefslogtreecommitdiffstats
path: root/src/history_test.go
diff options
context:
space:
mode:
authorMichael Kelley <michael.kelley@here.com>2016-10-23 20:45:45 -0700
committerJunegunn Choi <junegunn.c@gmail.com>2016-11-07 02:32:14 +0900
commit26895da96918f9b1956a04981c8af5f3e42fcbd8 (patch)
tree189b7c8f639bda4f8d4e5aee838e59be48c69044 /src/history_test.go
parent0c573b3dffe806253e1df2447754a5f3939a11f0 (diff)
Implement tcell-based renderer
Diffstat (limited to 'src/history_test.go')
-rw-r--r--src/history_test.go28
1 files changed, 21 insertions, 7 deletions
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))
}