posix: Return errDiskNotWritable during disk initialization. (#2048)

It can happen that minio server might not have
writable permissions on the export paths command line.

Fixes #2035
This commit is contained in:
Harshavardhana
2016-07-02 01:59:28 -07:00
committed by Anand Babu (AB) Periasamy
parent e5dd917c37
commit d64c3fd464
9 changed files with 131 additions and 27 deletions
+44
View File
@@ -19,6 +19,7 @@ package main
import (
"io/ioutil"
"os"
"syscall"
"testing"
)
@@ -114,3 +115,46 @@ func TestReadAll(t *testing.T) {
}
}
}
// TestNewPosix all the cases handled in posix storage layer initialization.
func TestNewPosix(t *testing.T) {
// Temporary dir name.
tmpDirName := os.TempDir() + "/" + "minio-" + nextSuffix()
// Temporary file name.
tmpFileName := os.TempDir() + "/" + "minio-" + nextSuffix()
f, _ := os.Create(tmpFileName)
f.Close()
defer os.Remove(tmpFileName)
// List of all tests for posix initialization.
testCases := []struct {
diskPath string
err error
}{
// Validates input argument cannot be empty.
{
"",
errInvalidArgument,
},
// Validates if the directory does not exist and
// gets automatically created.
{
tmpDirName,
nil,
},
// Validates if the disk exists as file and returns error
// not a directory.
{
tmpFileName,
syscall.ENOTDIR,
},
}
// Validate all test cases.
for i, testCase := range testCases {
_, err := newPosix(testCase.diskPath)
if err != testCase.err {
t.Fatalf("Test %d failed wanted: %s, got: %s", i+1, err, testCase.err)
}
}
}