Reviewers: mp+194975_code.launchpad.net,
Message: Please take a look.
Description: instance container method tests
Be explicit in the container type equality. Test the parsing of KVM. Change the tests names to be consistent with the functions.
https://code.launchpad.net/~thumper/juju-core/better-container-instance-tests/+merge/194975
(do not edit description out of merge proposal)
Please review this at https://codereview.appspot.com/25460045/
Affected files (+24, -6 lines): A [revision details] M instance/container_test.go
Index: [revision details] === added file '[revision details]' --- [revision details] 2012-01-01 00:00:00 +0000 +++ [revision details] 2012-01-01 00:00:00 +0000 @@ -0,0 +1,2 @@ +Old revision: tarmac-20131113015012-y3lnl9jzz40v7h6v +New revision: <email address hidden>
Index: instance/container_test.go === modified file 'instance/container_test.go' --- instance/container_test.go 2013-11-12 01:59:52 +0000 +++ instance/container_test.go 2013-11-13 01:40:16 +0000 @@ -19,19 +19,35 @@
var _ = gc.Suite(&InstanceSuite{})
-func (s *InstanceSuite) TestParseAllowedContainerType(c *gc.C) { +func (s *InstanceSuite) TestParseContainerType(c *gc.C) { ctype, err := instance.ParseContainerType("lxc") c.Assert(err, gc.IsNil) - c.Assert(ctype, gc.Equals, instance.ContainerType("lxc")) + c.Assert(ctype, gc.Equals, instance.LXC) + + ctype, err = instance.ParseContainerType("kvm") + c.Assert(err, gc.IsNil) + c.Assert(ctype, gc.Equals, instance.KVM) + ctype, err = instance.ParseContainerType("none") - c.Assert(err, gc.Not(gc.IsNil)) + c.Assert(err, gc.ErrorMatches, `invalid container type "none"`) + + ctype, err = instance.ParseContainerType("omg") + c.Assert(err, gc.ErrorMatches, `invalid container type "omg"`) }
-func (s *InstanceSuite) TestParseAllowedContainerTypeOrNone(c *gc.C) { +func (s *InstanceSuite) TestParseContainerTypeOrNone(c *gc.C) { ctype, err := instance.ParseContainerTypeOrNone("lxc") c.Assert(err, gc.IsNil) - c.Assert(ctype, gc.Equals, instance.ContainerType("lxc")) + c.Assert(ctype, gc.Equals, instance.LXC) + + ctype, err = instance.ParseContainerTypeOrNone("kvm") + c.Assert(err, gc.IsNil) + c.Assert(ctype, gc.Equals, instance.KVM) + ctype, err = instance.ParseContainerTypeOrNone("none") c.Assert(err, gc.IsNil) - c.Assert(ctype, gc.Equals, instance.ContainerType("none")) + c.Assert(ctype, gc.Equals, instance.NONE) + + ctype, err = instance.ParseSupportedContainerTypeOrNone("omg") + c.Assert(err, gc.ErrorMatches, `invalid container type "omg"`) }
« Back to merge proposal
Reviewers: mp+194975_ code.launchpad. net,
Message:
Please take a look.
Description:
instance container method tests
Be explicit in the container type equality.
Test the parsing of KVM.
Change the tests names to be consistent with the functions.
https:/ /code.launchpad .net/~thumper/ juju-core/ better- container- instance- tests/+ merge/194975
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/25460045/
Affected files (+24, -6 lines): container_ test.go
A [revision details]
M instance/
Index: [revision details] 20131113015012- y3lnl9jzz40v7h6 v
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-
+New revision: <email address hidden>
Index: instance/ container_ test.go container_ test.go' container_ test.go 2013-11-12 01:59:52 +0000 container_ test.go 2013-11-13 01:40:16 +0000
=== modified file 'instance/
--- instance/
+++ instance/
@@ -19,19 +19,35 @@
var _ = gc.Suite( &InstanceSuite{ })
-func (s *InstanceSuite) TestParseAllowe dContainerType( c *gc.C) { nerType( c *gc.C) { ParseContainerT ype("lxc" ) ContainerType( "lxc")) ParseContainerT ype("kvm" ) ParseContainerT ype("none" ) ParseContainerT ype("omg" )
+func (s *InstanceSuite) TestParseContai
ctype, err := instance.
c.Assert(err, gc.IsNil)
- c.Assert(ctype, gc.Equals, instance.
+ c.Assert(ctype, gc.Equals, instance.LXC)
+
+ ctype, err = instance.
+ c.Assert(err, gc.IsNil)
+ c.Assert(ctype, gc.Equals, instance.KVM)
+
ctype, err = instance.
- c.Assert(err, gc.Not(gc.IsNil))
+ c.Assert(err, gc.ErrorMatches, `invalid container type "none"`)
+
+ ctype, err = instance.
+ c.Assert(err, gc.ErrorMatches, `invalid container type "omg"`)
}
-func (s *InstanceSuite) TestParseAllowe dContainerTypeO rNone(c *gc.C) { nerTypeOrNone( c *gc.C) { ParseContainerT ypeOrNone( "lxc") ContainerType( "lxc")) ParseContainerT ypeOrNone( "kvm") ParseContainerT ypeOrNone( "none") ContainerType( "none") ) ParseSupportedC ontainerTypeOrN one("omg" )
+func (s *InstanceSuite) TestParseContai
ctype, err := instance.
c.Assert(err, gc.IsNil)
- c.Assert(ctype, gc.Equals, instance.
+ c.Assert(ctype, gc.Equals, instance.LXC)
+
+ ctype, err = instance.
+ c.Assert(err, gc.IsNil)
+ c.Assert(ctype, gc.Equals, instance.KVM)
+
ctype, err = instance.
c.Assert(err, gc.IsNil)
- c.Assert(ctype, gc.Equals, instance.
+ c.Assert(ctype, gc.Equals, instance.NONE)
+
+ ctype, err = instance.
+ c.Assert(err, gc.ErrorMatches, `invalid container type "omg"`)
}