9581: add json config file handling to slurm dispatcher.
[arvados.git] / services / datamanager / datamanager_test.go
index a99ec6b05252714c1ed3b21ce6dbf055a6dfd846..0ff6b777344d2f5377cc984b5c3f3496d7fcdc13 100644 (file)
@@ -538,32 +538,31 @@ func TestPutAndGetBlocks_NoErrorDuringSingleRun(t *testing.T) {
        testOldBlocksNotDeletedOnDataManagerError(t, "", "", false, false)
 }
 
-func createBadPath(t *testing.T) (badpath string) {
-       tempdir, err := ioutil.TempDir("", "bad")
-       if err != nil {
-               t.Fatalf("Could not create temporary directory for bad path: %v", err)
-       }
-       badpath = path.Join(tempdir, "bad")
-       return
-}
-
-func destroyBadPath(t *testing.T, badpath string) {
-       tempdir := path.Join(badpath, "..")
-       err := os.Remove(tempdir)
+func TestPutAndGetBlocks_ErrorDuringGetCollectionsBadWriteTo(t *testing.T) {
+       badpath, err := arvadostest.CreateBadPath()
        if err != nil {
-               t.Fatalf("Could not remove bad path temporary directory %v: %v", tempdir, err)
+               t.Fatalf(err.Error())
        }
-}
-
-func TestPutAndGetBlocks_ErrorDuringGetCollectionsBadWriteTo(t *testing.T) {
-       badpath := createBadPath(t)
-       defer destroyBadPath(t, badpath)
+       defer func() {
+               err = arvadostest.DestroyBadPath(badpath)
+               if err != nil {
+                       t.Fatalf(err.Error())
+               }
+       }()
        testOldBlocksNotDeletedOnDataManagerError(t, path.Join(badpath, "writetofile"), "", true, true)
 }
 
 func TestPutAndGetBlocks_ErrorDuringGetCollectionsBadHeapProfileFilename(t *testing.T) {
-       badpath := createBadPath(t)
-       defer destroyBadPath(t, badpath)
+       badpath, err := arvadostest.CreateBadPath()
+       if err != nil {
+               t.Fatalf(err.Error())
+       }
+       defer func() {
+               err = arvadostest.DestroyBadPath(badpath)
+               if err != nil {
+                       t.Fatalf(err.Error())
+               }
+       }()
        testOldBlocksNotDeletedOnDataManagerError(t, "", path.Join(badpath, "heapprofilefile"), true, true)
 }