From 9bf0d67fdd76038097e185278488080d1a64b555 Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Wed, 25 Dec 2019 01:47:07 -0800 Subject: [PATCH] ut: direct factory needs to set VCStorePrefix Otherwise it fails with permission errors. Signed-off-by: Peng Tao --- virtcontainers/factory/direct/direct_test.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/virtcontainers/factory/direct/direct_test.go b/virtcontainers/factory/direct/direct_test.go index cca51cea97..5ca7df2986 100644 --- a/virtcontainers/factory/direct/direct_test.go +++ b/virtcontainers/factory/direct/direct_test.go @@ -8,17 +8,26 @@ package direct import ( "context" "io/ioutil" + "os" "testing" "github.com/stretchr/testify/assert" vc "github.com/kata-containers/runtime/virtcontainers" + "github.com/kata-containers/runtime/virtcontainers/store" ) func TestTemplateFactory(t *testing.T) { assert := assert.New(t) - testDir, _ := ioutil.TempDir("", "vmfactory-tmp-") + testDir, err := ioutil.TempDir("", "vmfactory-tmp-") + assert.Nil(err) + store.VCStorePrefix = testDir + defer func() { + os.RemoveAll(testDir) + store.VCStorePrefix = "" + }() + hyperConfig := vc.HypervisorConfig{ KernelPath: testDir, ImagePath: testDir,