Skip to content

Commit

Permalink
watch: fix a dumb errcheck (#3622)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicks committed Jul 27, 2020
1 parent 39544b5 commit 143c02c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/watch/notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func DesiredWindowsBufferSize() int {
envVar := os.Getenv(WindowsBufferSizeEnvVar)
if envVar != "" {
size, err := strconv.Atoi(envVar)
if err != nil {
if err == nil {
return size
}
}
Expand Down
14 changes: 14 additions & 0 deletions internal/watch/notify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,20 @@ import (
// Each implementation of the notify interface should have the same basic
// behavior.

func TestWindowsBufferSize(t *testing.T) {
orig := os.Getenv(WindowsBufferSizeEnvVar)
defer os.Setenv(WindowsBufferSizeEnvVar, orig)

os.Setenv(WindowsBufferSizeEnvVar, "")
assert.Equal(t, defaultBufferSize, DesiredWindowsBufferSize())

os.Setenv(WindowsBufferSizeEnvVar, "a")
assert.Equal(t, defaultBufferSize, DesiredWindowsBufferSize())

os.Setenv(WindowsBufferSizeEnvVar, "10")
assert.Equal(t, 10, DesiredWindowsBufferSize())
}

func TestNoEvents(t *testing.T) {
f := newNotifyFixture(t)
defer f.tearDown()
Expand Down

0 comments on commit 143c02c

Please sign in to comment.