mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-24 18:52:08 +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{
|
config.VMConfig = vc.VMConfig{
|
||||||
HypervisorType: vc.MockHypervisor,
|
HypervisorType: vc.MockHypervisor,
|
||||||
AgentType: vc.NoopAgentType,
|
AgentType: vc.NoopAgentType,
|
||||||
|
ProxyType: vc.NoopProxyType,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = NewFactory(ctx, config, false)
|
_, err = NewFactory(ctx, config, false)
|
||||||
@ -43,28 +44,33 @@ func TestNewFactory(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// direct
|
// direct
|
||||||
_, err = NewFactory(ctx, config, false)
|
f, err := NewFactory(ctx, config, false)
|
||||||
assert.Nil(err)
|
assert.Nil(err)
|
||||||
_, err = NewFactory(ctx, config, true)
|
f.CloseFactory(ctx)
|
||||||
|
f, err = NewFactory(ctx, config, true)
|
||||||
assert.Nil(err)
|
assert.Nil(err)
|
||||||
|
f.CloseFactory(ctx)
|
||||||
|
|
||||||
// template
|
// template
|
||||||
config.Template = true
|
config.Template = true
|
||||||
_, err = NewFactory(ctx, config, false)
|
f, err = NewFactory(ctx, config, false)
|
||||||
assert.Nil(err)
|
assert.Nil(err)
|
||||||
|
f.CloseFactory(ctx)
|
||||||
_, err = NewFactory(ctx, config, true)
|
_, err = NewFactory(ctx, config, true)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
|
|
||||||
// Cache
|
// Cache
|
||||||
config.Cache = 10
|
config.Cache = 10
|
||||||
_, err = NewFactory(ctx, config, false)
|
f, err = NewFactory(ctx, config, false)
|
||||||
assert.Nil(err)
|
assert.Nil(err)
|
||||||
|
f.CloseFactory(ctx)
|
||||||
_, err = NewFactory(ctx, config, true)
|
_, err = NewFactory(ctx, config, true)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
|
|
||||||
config.Template = false
|
config.Template = false
|
||||||
_, err = NewFactory(ctx, config, false)
|
f, err = NewFactory(ctx, config, false)
|
||||||
assert.Nil(err)
|
assert.Nil(err)
|
||||||
|
f.CloseFactory(ctx)
|
||||||
_, err = NewFactory(ctx, config, true)
|
_, err = NewFactory(ctx, config, true)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user