summaryrefslogtreecommitdiff
path: root/src/reader_test.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2024-11-03 15:14:35 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2024-11-03 20:12:47 +0900
commit19495eb9bbfa874647e7bc69e0fdff49d68b1dcf (patch)
treefeec000483143382c365d5d68dbce41860af9b4c /src/reader_test.go
parentbacc8609ee22fb9bbe34dc812ecb6075f4e58007 (diff)
downloadfzf-19495eb9bbfa874647e7bc69e0fdff49d68b1dcf.tar.gz
Remove possible races (#4070)
Diffstat (limited to 'src/reader_test.go')
-rw-r--r--src/reader_test.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/reader_test.go b/src/reader_test.go
index 56f9a1b0..cab4c017 100644
--- a/src/reader_test.go
+++ b/src/reader_test.go
@@ -23,8 +23,12 @@ func TestReadFromCommand(t *testing.T) {
}
// Normal command
- reader.fin(reader.readFromCommand(`echo abc&&echo def`, nil))
- if len(strs) != 2 || strs[0] != "abc" || strs[1] != "def" {
+ counter := 0
+ ready := func() {
+ counter++
+ }
+ reader.fin(reader.readFromCommand(`echo abc&&echo def`, nil, ready))
+ if len(strs) != 2 || strs[0] != "abc" || strs[1] != "def" || counter != 1 {
t.Errorf("%s", strs)
}
@@ -48,9 +52,9 @@ func TestReadFromCommand(t *testing.T) {
reader.startEventPoller()
// Failing command
- reader.fin(reader.readFromCommand(`no-such-command`, nil))
+ reader.fin(reader.readFromCommand(`no-such-command`, nil, ready))
strs = []string{}
- if len(strs) > 0 {
+ if len(strs) > 0 || counter != 2 {
t.Errorf("%s", strs)
}