store: UT tmp path should be random

Otherwise we might end up using the previously created store instead.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
This commit is contained in:
Peng Tao 2019-12-25 02:07:52 -08:00
parent 5617120649
commit 3ed472dc8d
2 changed files with 10 additions and 3 deletions

View File

@ -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) {

View File

@ -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) {