-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't return typed nil interface values #46
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,11 @@ type interfaceSuite struct { | |
|
||
var _ = gc.Suite(&interfaceSuite{}) | ||
|
||
func (*interfaceSuite) TestNilVLAN(c *gc.C) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. |
||
var empty interface_ | ||
c.Check(empty.VLAN() == nil, jc.IsTrue) | ||
} | ||
|
||
func (*interfaceSuite) TestReadInterfacesBadSchema(c *gc.C) { | ||
_, err := readInterfaces(twoDotOh, "wat?") | ||
c.Check(err, jc.Satisfies, IsDeserializationError) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,11 @@ type linkSuite struct{} | |
|
||
var _ = gc.Suite(&linkSuite{}) | ||
|
||
func (*linkSuite) TestNilSubnet(c *gc.C) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. |
||
var empty link | ||
c.Check(empty.Subnet() == nil, jc.IsTrue) | ||
} | ||
|
||
func (*linkSuite) TestReadLinksBadSchema(c *gc.C) { | ||
_, err := readLinks(twoDotOh, "wat?") | ||
c.Check(err, jc.Satisfies, IsDeserializationError) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,14 @@ type machineSuite struct { | |
|
||
var _ = gc.Suite(&machineSuite{}) | ||
|
||
func (*machineSuite) TestNilGetters(c *gc.C) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Likewise here |
||
var empty machine | ||
c.Check(empty.Zone() == nil, jc.IsTrue) | ||
c.Check(empty.PhysicalBlockDevice(0) == nil, jc.IsTrue) | ||
c.Check(empty.Interface(0) == nil, jc.IsTrue) | ||
c.Check(empty.BootInterface() == nil, jc.IsTrue) | ||
} | ||
|
||
func (*machineSuite) TestReadMachinesBadSchema(c *gc.C) { | ||
_, err := readMachines(twoDotOh, "wat?") | ||
c.Check(err, jc.Satisfies, IsDeserializationError) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,11 @@ type partitionSuite struct{} | |
|
||
var _ = gc.Suite(&partitionSuite{}) | ||
|
||
func (*partitionSuite) TestNilFileSystem(c *gc.C) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. |
||
var empty partition | ||
c.Assert(empty.FileSystem() == nil, jc.IsTrue) | ||
} | ||
|
||
func (*partitionSuite) TestReadPartitionsBadSchema(c *gc.C) { | ||
_, err := readPartitions(twoDotOh, "wat?") | ||
c.Check(err, jc.Satisfies, IsDeserializationError) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,11 @@ type subnetSuite struct{} | |
|
||
var _ = gc.Suite(&subnetSuite{}) | ||
|
||
func (*subnetSuite) TestNilVLAN(c *gc.C) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ...and here |
||
var empty subnet | ||
c.Check(empty.VLAN() == nil, jc.IsTrue) | ||
} | ||
|
||
func (*subnetSuite) TestReadSubnetsBadSchema(c *gc.C) { | ||
_, err := readSubnets(twoDotOh, "wat?") | ||
c.Assert(err.Error(), gc.Equals, `subnet base schema check failed: expected list, got string("wat?")`) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or alternatively:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried that first, but it uses reflection so didn't fail before I fixed the problem.