mirror of
https://github.com/aljazceru/kata-containers.git
synced 2025-12-17 22:34:25 +01:00
This PR will delete agent abstraction and use Kata agent as the only one agent. Fixes: #377 Signed-off-by: bin liu <bin@hyper.sh>
52 lines
989 B
Go
52 lines
989 B
Go
// Copyright (c) 2018 HyperHQ Inc.
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
package direct
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
vc "github.com/kata-containers/kata-containers/src/runtime/virtcontainers"
|
|
"github.com/kata-containers/kata-containers/src/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,
|
|
ProxyType: vc.NoopProxyType,
|
|
HypervisorConfig: hyperConfig,
|
|
}
|
|
|
|
ctx := vc.WithNewAgentFunc(context.Background(), vc.NewMockAgent)
|
|
|
|
// New
|
|
f := 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)
|
|
}
|