mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-27 15:57:09 +00:00
vc/store: fix TestStoreVCNewVCSandboxStore/TestStoreVCNewVCContainerStore
They both need to set a temporary test dir in order to run as non-root. Signed-off-by: Peng Tao <bergwolf@hyper.sh>
This commit is contained in:
parent
6ab89e4549
commit
dd21046072
@ -8,6 +8,8 @@ package store
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@ -99,6 +101,17 @@ func TestStoreVCSandboxFileNegative(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStoreVCNewVCSandboxStore(t *testing.T) {
|
||||
testDir, _ := ioutil.TempDir("", "vmfactory-tmp-")
|
||||
defer func() {
|
||||
os.RemoveAll(testDir)
|
||||
}()
|
||||
|
||||
var savedStorePath = VCStorePrefix
|
||||
VCStorePrefix = testDir
|
||||
defer func() {
|
||||
VCStorePrefix = savedStorePath
|
||||
}()
|
||||
|
||||
_, err := NewVCSandboxStore(context.Background(), testSandboxID)
|
||||
assert.Nil(t, err)
|
||||
|
||||
@ -107,6 +120,17 @@ func TestStoreVCNewVCSandboxStore(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStoreVCNewVCContainerStore(t *testing.T) {
|
||||
testDir, _ := ioutil.TempDir("", "vmfactory-tmp-")
|
||||
defer func() {
|
||||
os.RemoveAll(testDir)
|
||||
}()
|
||||
|
||||
var savedStorePath = VCStorePrefix
|
||||
VCStorePrefix = testDir
|
||||
defer func() {
|
||||
VCStorePrefix = savedStorePath
|
||||
}()
|
||||
|
||||
_, err := NewVCContainerStore(context.Background(), testSandboxID, "foobar")
|
||||
assert.Nil(t, err)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user