From 8b39322365d61d35b2df89b32f312d184f6e9694 Mon Sep 17 00:00:00 2001 From: Nick Santos Date: Mon, 27 Jul 2020 19:36:15 -0400 Subject: [PATCH] watch: fix a dumb errcheck (#3622) --- pkg/watch/notify.go | 2 +- pkg/watch/notify_test.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) 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()