watch: fix a dumb errcheck (#3622)

This commit is contained in:
Nick Santos 2020-07-27 19:36:15 -04:00 committed by Nicolas De loof
parent b3615d64e2
commit 8b39322365
2 changed files with 15 additions and 1 deletions

View File

@ -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
}
}

View File

@ -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()