Skip to content

Commit

Permalink
Inotify: Fix tests to pass go vet
Browse files Browse the repository at this point in the history
  • Loading branch information
alvaroaleman committed Mar 21, 2022
1 parent 5afd63f commit 5c43bf6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion inotify/inotify_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build linux
// +build linux

package inotify
Expand Down Expand Up @@ -34,9 +35,11 @@ func TestInotifyEvents(t *testing.T) {
}

// Receive errors on the error channel on a separate goroutine
var watcherErrs []error
go func() {
for err := range watcher.Error {
t.Fatalf("error received: %s", err)
// Fatal inside a goroutine is not allowed
watcherErrs = append(watcherErrs, err)
}
}()

Expand Down Expand Up @@ -82,6 +85,12 @@ func TestInotifyEvents(t *testing.T) {
case <-time.After(1 * time.Second):
t.Fatal("event stream was not closed after 1 second")
}

for _, err := range watcherErrs {
if err != nil {
t.Errorf("watcher had error: %v", err)
}
}
}

func TestInotifyClose(t *testing.T) {
Expand Down

0 comments on commit 5c43bf6

Please sign in to comment.