-
Notifications
You must be signed in to change notification settings - Fork 0
/
factory_test.go
52 lines (46 loc) · 1.22 KB
/
factory_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2013 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package factory_test
import (
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
"github.com/juju/juju/container"
"github.com/juju/juju/container/factory"
"github.com/juju/juju/core/instance"
"github.com/juju/juju/testing"
)
type factorySuite struct {
testing.BaseSuite
}
var _ = gc.Suite(&factorySuite{})
func (*factorySuite) TestNewContainerManager(c *gc.C) {
for _, test := range []struct {
containerType instance.ContainerType
valid bool
}{{
containerType: instance.LXD,
valid: true,
}, {
containerType: instance.LXD,
valid: true,
}, {
containerType: instance.KVM,
valid: true,
}, {
containerType: instance.NONE,
valid: false,
}, {
containerType: instance.ContainerType("other"),
valid: false,
}} {
conf := container.ManagerConfig{container.ConfigModelUUID: testing.ModelTag.Id()}
manager, err := factory.NewContainerManager(test.containerType, conf)
if test.valid {
c.Assert(err, jc.ErrorIsNil)
c.Assert(manager, gc.NotNil)
} else {
c.Assert(err, gc.ErrorMatches, `unknown container type: ".*"`)
c.Assert(manager, gc.IsNil)
}
}
}