Esempio n. 1
0
func (s *ipAddressSuite) TestParseIPAddressTag(c *gc.C) {
	for i, t := range parseIPAddressTagTests {
		c.Logf("test %d: %s", i, t.tag)
		got, err := names.ParseIPAddressTag(t.tag)
		if err != nil || t.err != nil {
			c.Check(err, gc.DeepEquals, t.err)
			continue
		}
		c.Check(got, gc.FitsTypeOf, t.expected)
		c.Check(got, gc.Equals, t.expected)
	}
}
Esempio n. 2
0
func (s *ipAddressSuite) TestNewIPAddressTag(c *gc.C) {
	uuid := utils.MustNewUUID()
	tag := names.NewIPAddressTag(uuid.String())
	parsed, err := names.ParseIPAddressTag(tag.String())
	c.Assert(err, gc.IsNil)
	c.Assert(parsed.Kind(), gc.Equals, names.IPAddressTagKind)
	c.Assert(parsed.Id(), gc.Equals, uuid.String())
	c.Assert(parsed.String(), gc.Equals, names.IPAddressTagKind+"-"+uuid.String())

	f := func() {
		tag = names.NewIPAddressTag("42")
	}
	c.Assert(f, gc.PanicMatches, `invalid UUID: "42"`)
}