tests: Use testTmpDir var to specify tmp directory (#3459)

To be able to specify the directory where tests will be done.  This way,
it will be easier to run Minio tests on a mounted directory like NFS, ..
This commit is contained in:
Anis Elleuch
2016-12-16 07:25:05 +01:00
committed by Harshavardhana
parent 0db484c8f6
commit 8ceb969445
12 changed files with 43 additions and 45 deletions

View File

@@ -31,7 +31,7 @@ import (
// creates a temp dir and sets up posix layer.
// returns posix layer, temp dir path to be used for the purpose of tests.
func newPosixTestSetup() (StorageAPI, string, error) {
diskPath, err := ioutil.TempDir(os.TempDir(), "minio-")
diskPath, err := ioutil.TempDir(globalTestTmpDir, "minio-")
if err != nil {
return nil, "", err
}
@@ -45,7 +45,7 @@ func newPosixTestSetup() (StorageAPI, string, error) {
// Tests posix.getDiskInfo()
func TestGetDiskInfo(t *testing.T) {
path, err := ioutil.TempDir(os.TempDir(), "minio-")
path, err := ioutil.TempDir(globalTestTmpDir, "minio-")
if err != nil {
t.Fatalf("Unable to create a temporary directory, %s", err)
}
@@ -171,9 +171,9 @@ 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()
tmpDirName := globalTestTmpDir + "/" + "minio-" + nextSuffix()
// Temporary file name.
tmpFileName := os.TempDir() + "/" + "minio-" + nextSuffix()
tmpFileName := globalTestTmpDir + "/" + "minio-" + nextSuffix()
f, _ := os.Create(tmpFileName)
f.Close()
defer os.Remove(tmpFileName)