]> go.fuhry.dev Git - fsnotify.git/commitdiff
tests: fix error reporting from Mkdir calls
authorFrancisco Souza <f@souza.cc>
Wed, 6 Feb 2013 19:02:58 +0000 (17:02 -0200)
committerFrancisco Souza <f@souza.cc>
Wed, 6 Feb 2013 19:02:58 +0000 (17:02 -0200)
Whenever the creation of a directory fails, it was trying to report an
error from an outer scope.

fsnotify_test.go

index e5c5ddd0f51fe475aa4d1593194a77d9953f0587..1bfd9eda1a5b32dd0a09c1b57d0e3bc86b9c5778 100644 (file)
@@ -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)