From: Francisco Souza Date: Wed, 6 Feb 2013 19:02:58 +0000 (-0200) Subject: tests: fix error reporting from Mkdir calls X-Git-Tag: v1.7.2~387^2~1 X-Git-Url: https://go.fuhry.dev/?a=commitdiff_plain;h=48230eb450fdc9dbe0c4e0536c8e1d7343e48fb1;p=fsnotify.git tests: fix error reporting from Mkdir calls Whenever the creation of a directory fails, it was trying to report an error from an outer scope. --- diff --git a/fsnotify_test.go b/fsnotify_test.go index e5c5ddd..1bfd9ed 100644 --- a/fsnotify_test.go +++ b/fsnotify_test.go @@ -29,13 +29,13 @@ func TestFsnotifyMultipleOperations(t *testing.T) { const testDirToMoveFiles string = "_test2" // Create directory to watch - if os.Mkdir(testDir, 0777) != nil { + if err := os.Mkdir(testDir, 0777); err != nil { t.Fatalf("Failed to create test directory: %s", err) } defer os.RemoveAll(testDir) // Create directory to that's not watched - if os.Mkdir(testDirToMoveFiles, 0777) != nil { + if err := os.Mkdir(testDirToMoveFiles, 0777); err != nil { t.Fatalf("Failed to create test directory: %s", err) } defer os.RemoveAll(testDirToMoveFiles) @@ -161,7 +161,7 @@ func TestFsnotifyMultipleCreates(t *testing.T) { const testDir string = "_test" // Create directory to watch - if os.Mkdir(testDir, 0777) != nil { + if err := os.Mkdir(testDir, 0777); err != nil { t.Fatalf("Failed to create test directory: %s", err) } defer os.RemoveAll(testDir) @@ -290,7 +290,7 @@ func TestFsnotifyDirOnly(t *testing.T) { const testDir string = "_test" // Create directory to watch - if os.Mkdir(testDir, 0777) != nil { + if err := os.Mkdir(testDir, 0777); err != nil { t.Fatalf("Failed to create test directory: %s", err) } defer os.RemoveAll(testDir) @@ -404,7 +404,7 @@ func TestFsnotifyDeleteWatchedDir(t *testing.T) { const testDir string = "_test" // Create directory to watch - if os.Mkdir(testDir, 0777) != nil { + if err := os.Mkdir(testDir, 0777); err != nil { t.Fatalf("Failed to create test directory: %s", err) } @@ -478,7 +478,7 @@ func TestFsnotifySubDir(t *testing.T) { const testSubDirFile string = "_test/sub/TestFsnotifyFile1.testfile" // Create directory to watch - if os.Mkdir(testDir, 0777) != nil { + if err := os.Mkdir(testDir, 0777); err != nil { t.Fatalf("Failed to create test directory: %s", err) } defer os.RemoveAll(testDir) @@ -520,7 +520,7 @@ func TestFsnotifySubDir(t *testing.T) { } // Create sub-directory - if os.Mkdir(testSubDir, 0777) != nil { + if err := os.Mkdir(testSubDir, 0777); err != nil { t.Fatalf("Failed to create test sub-directory: %s", err) } @@ -577,7 +577,7 @@ func TestFsnotifyRename(t *testing.T) { const testDir string = "_test" // Create directory to watch - if os.Mkdir(testDir, 0777) != nil { + if err := os.Mkdir(testDir, 0777); err != nil { t.Fatalf("Failed to create test directory: %s", err) } defer os.RemoveAll(testDir) @@ -673,13 +673,13 @@ func TestFsnotifyRenameToCreate(t *testing.T) { const testDirFrom string = "_testfrom" // Create directory to watch - if os.Mkdir(testDir, 0777) != nil { + if err := os.Mkdir(testDir, 0777); err != nil { t.Fatalf("Failed to create test directory: %s", err) } defer os.RemoveAll(testDir) // Create directory to get file - if os.Mkdir(testDirFrom, 0777) != nil { + if err := os.Mkdir(testDirFrom, 0777); err != nil { t.Fatalf("Failed to create test directory: %s", err) } defer os.RemoveAll(testDirFrom) @@ -769,13 +769,13 @@ func TestFsnotifyRenameToOverwrite(t *testing.T) { const testFileRenamed string = "_test/TestFsnotifyEvents.testfileRenamed" // Create directory to watch - if os.Mkdir(testDir, 0777) != nil { + if err := os.Mkdir(testDir, 0777); err != nil { t.Fatalf("Failed to create test directory: %s", err) } defer os.RemoveAll(testDir) // Create directory to get file - if os.Mkdir(testDirFrom, 0777) != nil { + if err := os.Mkdir(testDirFrom, 0777) != nil { t.Fatalf("Failed to create test directory: %s", err) } defer os.RemoveAll(testDirFrom) @@ -865,7 +865,7 @@ func TestFsnotifyAttrib(t *testing.T) { const testDir string = "_test" // Create directory to watch - if os.Mkdir(testDir, 0777) != nil { + if err := os.Mkdir(testDir, 0777); err != nil { t.Fatalf("Failed to create test directory: %s", err) } defer os.RemoveAll(testDir)