Files
kata-containers/virtcontainers/factory/cache/cache_test.go
Julio Montes 4b9ab557c8 virtcontainers/factory: support new persist API
Fix factory implementation and unit tests to support the new persist API

Signed-off-by: Julio Montes <julio.montes@intel.com>
2020-02-12 19:09:32 +00:00

54 lines
1.0 KiB
Go

// Copyright (c) 2018 HyperHQ Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
package cache
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
vc "github.com/kata-containers/runtime/virtcontainers"
"github.com/kata-containers/runtime/virtcontainers/factory/direct"
"github.com/kata-containers/runtime/virtcontainers/persist/fs"
)
func TestTemplateFactory(t *testing.T) {
assert := assert.New(t)
testDir := fs.MockStorageRootPath()
defer fs.MockStorageDestroy()
hyperConfig := vc.HypervisorConfig{
KernelPath: testDir,
ImagePath: testDir,
}
vmConfig := vc.VMConfig{
HypervisorType: vc.MockHypervisor,
AgentType: vc.NoopAgentType,
ProxyType: vc.NoopProxyType,
HypervisorConfig: hyperConfig,
}
ctx := context.Background()
// New
f := New(ctx, 2, direct.New(ctx, vmConfig))
// Config
assert.Equal(f.Config(), vmConfig)
// GetBaseVM
vm, err := f.GetBaseVM(ctx, vmConfig)
assert.Nil(err)
err = vm.Stop()
assert.Nil(err)
// CloseFactory
f.CloseFactory(ctx)
}