github.com/rogpeppe/juju@v0.0.0-20140613142852-6337964b789e/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  	gc "launchpad.net/gocheck"
     8  
     9  	"github.com/juju/juju/container"
    10  	"github.com/juju/juju/container/factory"
    11  	"github.com/juju/juju/instance"
    12  	"github.com/juju/juju/testing"
    13  )
    14  
    15  type factorySuite struct {
    16  	testing.BaseSuite
    17  }
    18  
    19  var _ = gc.Suite(&factorySuite{})
    20  
    21  func (*factorySuite) TestNewContainerManager(c *gc.C) {
    22  	for _, test := range []struct {
    23  		containerType instance.ContainerType
    24  		valid         bool
    25  	}{{
    26  		containerType: instance.LXC,
    27  		valid:         true,
    28  	}, {
    29  		containerType: instance.KVM,
    30  		valid:         true,
    31  	}, {
    32  		containerType: instance.NONE,
    33  		valid:         false,
    34  	}, {
    35  		containerType: instance.ContainerType("other"),
    36  		valid:         false,
    37  	}} {
    38  		conf := container.ManagerConfig{container.ConfigName: "test"}
    39  		manager, err := factory.NewContainerManager(test.containerType, conf)
    40  		if test.valid {
    41  			c.Assert(err, gc.IsNil)
    42  			c.Assert(manager, gc.NotNil)
    43  		} else {
    44  			c.Assert(err, gc.ErrorMatches, `unknown container type: ".*"`)
    45  			c.Assert(manager, gc.IsNil)
    46  		}
    47  	}
    48  }