tests: helpers: fix a few error reports

These were using stale err values.
This commit is contained in:
Jakob Unterwurzacher 2018-04-27 20:19:51 +02:00
parent 12b32aa06c
commit 996d2f141b

View File

@ -294,8 +294,10 @@ func TestMkdirRmdir(t *testing.T, plainDir string) {
t.Error(err) t.Error(err)
return return
} }
// Removing a non-empty dir should fail with ENOTEMPTY // Create a directory and put a file in it
if os.Mkdir(dir, 0777) != nil { // Trying to rmdir it should fail with ENOTEMPTY
err = os.Mkdir(dir, 0777)
if err != nil {
t.Error(err) t.Error(err)
return return
} }
@ -308,13 +310,15 @@ func TestMkdirRmdir(t *testing.T, plainDir string) {
err = syscall.Rmdir(dir) err = syscall.Rmdir(dir)
errno := err.(syscall.Errno) errno := err.(syscall.Errno)
if errno != syscall.ENOTEMPTY { if errno != syscall.ENOTEMPTY {
t.Errorf("Should have gotten ENOTEMPTY, go %v", errno) t.Errorf("Should have gotten ENOTEMPTY, got %v", errno)
} }
if syscall.Unlink(dir+"/file") != nil { err = syscall.Unlink(dir + "/file")
if err != nil {
t.Error(err) t.Error(err)
return return
} }
if syscall.Rmdir(dir) != nil { err = syscall.Rmdir(dir)
if err != nil {
t.Error(err) t.Error(err)
return return
} }