diff --git a/pkg/watch/notify.go b/pkg/watch/notify.go index 86b66c32..5d7da04e 100644 --- a/pkg/watch/notify.go +++ b/pkg/watch/notify.go @@ -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 } } diff --git a/pkg/watch/notify_test.go b/pkg/watch/notify_test.go index d184d40d..97ae8201 100644 --- a/pkg/watch/notify_test.go +++ b/pkg/watch/notify_test.go @@ -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()