mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-04 02:56:18 +00:00
factory: close factory in UT
So that we do not leave artifacts like template mountpoint behind. Fixes: #763 Signed-off-by: Peng Tao <bergwolf@gmail.com>
This commit is contained in:
parent
b193f0f3d0
commit
67ffa2fd0c
@ -30,6 +30,7 @@ func TestNewFactory(t *testing.T) {
|
||||
config.VMConfig = vc.VMConfig{
|
||||
HypervisorType: vc.MockHypervisor,
|
||||
AgentType: vc.NoopAgentType,
|
||||
ProxyType: vc.NoopProxyType,
|
||||
}
|
||||
|
||||
_, err = NewFactory(ctx, config, false)
|
||||
@ -43,28 +44,33 @@ func TestNewFactory(t *testing.T) {
|
||||
}
|
||||
|
||||
// direct
|
||||
_, err = NewFactory(ctx, config, false)
|
||||
f, err := NewFactory(ctx, config, false)
|
||||
assert.Nil(err)
|
||||
_, err = NewFactory(ctx, config, true)
|
||||
f.CloseFactory(ctx)
|
||||
f, err = NewFactory(ctx, config, true)
|
||||
assert.Nil(err)
|
||||
f.CloseFactory(ctx)
|
||||
|
||||
// template
|
||||
config.Template = true
|
||||
_, err = NewFactory(ctx, config, false)
|
||||
f, err = NewFactory(ctx, config, false)
|
||||
assert.Nil(err)
|
||||
f.CloseFactory(ctx)
|
||||
_, err = NewFactory(ctx, config, true)
|
||||
assert.Error(err)
|
||||
|
||||
// Cache
|
||||
config.Cache = 10
|
||||
_, err = NewFactory(ctx, config, false)
|
||||
f, err = NewFactory(ctx, config, false)
|
||||
assert.Nil(err)
|
||||
f.CloseFactory(ctx)
|
||||
_, err = NewFactory(ctx, config, true)
|
||||
assert.Error(err)
|
||||
|
||||
config.Template = false
|
||||
_, err = NewFactory(ctx, config, false)
|
||||
f, err = NewFactory(ctx, config, false)
|
||||
assert.Nil(err)
|
||||
f.CloseFactory(ctx)
|
||||
_, err = NewFactory(ctx, config, true)
|
||||
assert.Error(err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user