Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
store: UT tmp path should be random
Browse files Browse the repository at this point in the history
Otherwise we might end up using the previously created store instead.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
  • Loading branch information
bergwolf committed Dec 26, 2019
1 parent 5617120 commit 3ed472d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 5 additions & 1 deletion virtcontainers/store/filesystem_backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ type TestNoopStructure struct {
Field2 string
}

var rootPath = "/tmp/root1/"
var rootPath = func() string {
dir, _ := ioutil.TempDir("", "")
return dir
}()

var expectedFilesystemData = "{\"Field1\":\"value1\",\"Field2\":\"value2\"}"

func TestStoreFilesystemStore(t *testing.T) {
Expand Down
7 changes: 5 additions & 2 deletions virtcontainers/store/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@ var sandboxDirState = ""
var sandboxDirLock = ""
var sandboxFileState = ""
var sandboxFileLock = ""
var storeRoot = "file:///tmp/root1/"
var storeRoot, storeRootDir = func() (string, string) {
dir, _ := ioutil.TempDir("", "")
return "file://" + dir, dir
}()

func TestNewStore(t *testing.T) {
s, err := New(context.Background(), storeRoot)
assert.Nil(t, err)
assert.Equal(t, s.scheme, "file")
assert.Equal(t, s.host, "")
assert.Equal(t, s.path, "/tmp/root1/")
assert.Equal(t, s.path, storeRootDir)
}

func TestDeleteStore(t *testing.T) {
Expand Down

0 comments on commit 3ed472d

Please sign in to comment.