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

Commit

Permalink
vc/store: fix TestStoreVCNewVCSandboxStore/TestStoreVCNewVCContainerS…
Browse files Browse the repository at this point in the history
…tore

They both need to set a temporary test dir in order to run as non-root.

Signed-off-by: Peng Tao <[email protected]>
  • Loading branch information
bergwolf committed Oct 8, 2019
1 parent 6ab89e4 commit dd21046
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions virtcontainers/store/vc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ package store
import (
"context"
"fmt"
"io/ioutil"
"os"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand Down

0 comments on commit dd21046

Please sign in to comment.