github.com/altoros/juju-vmware@v0.0.0-20150312064031-f19ae857ccca/container/factory/factory_test.go (about)

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