mirror of
https://github.com/pgsty/minio.git
synced 2026-07-19 04:00:25 +03:00
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:
committed by
Anand Babu (AB) Periasamy
parent
e5dd917c37
commit
d64c3fd464
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user