X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/a87af13d2d3461470b89b0811629a077a70c1938..86e1730f97383b3ae1685445323aa253b99ee821:/services/datamanager/datamanager_test.go diff --git a/services/datamanager/datamanager_test.go b/services/datamanager/datamanager_test.go index a99ec6b052..0ff6b77734 100644 --- a/services/datamanager/datamanager_test.go +++ b/services/datamanager/datamanager_test.go @@ -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) }