Exemple #1
0
func (s *funcSuite) TestParseMetadataCustom(c *gc.C) {
	m := imagemetadata.ParseMetadataFromParams(params.CloudImageMetadata{Source: "custom"})
	c.Assert(m, gc.DeepEquals, s.expected)

	m = imagemetadata.ParseMetadataFromParams(params.CloudImageMetadata{Source: "CusTOM"})
	c.Assert(m, gc.DeepEquals, s.expected)
}
Exemple #2
0
func (s *funcSuite) TestParseMetadataPublic(c *gc.C) {
	s.expected.Source = cloudimagemetadata.Public

	m := imagemetadata.ParseMetadataFromParams(params.CloudImageMetadata{Source: "public"})
	c.Assert(m, gc.DeepEquals, s.expected)

	m = imagemetadata.ParseMetadataFromParams(params.CloudImageMetadata{Source: "PubLic"})
	c.Assert(m, gc.DeepEquals, s.expected)
}
func (s *funcSuite) TestParseMetadataAnyRegion(c *gc.C) {
	region := "region"
	s.expected.Region = region

	m, err := imagemetadata.ParseMetadataFromParams(s.api, params.CloudImageMetadata{Region: region}, s.env)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(m, gc.DeepEquals, s.expected)
}
func (s *funcSuite) TestParseMetadataAnyStream(c *gc.C) {
	stream := "happy stream"
	s.expected.Stream = stream

	m, err := imagemetadata.ParseMetadataFromParams(s.api, params.CloudImageMetadata{Stream: stream}, s.env)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(m, gc.DeepEquals, s.expected)
}
Exemple #5
0
func (s *funcSuite) TestParseMetadataAnyStream(c *gc.C) {
	stream := "happy stream"
	s.expected.Stream = stream

	m := imagemetadata.ParseMetadataFromParams(params.CloudImageMetadata{
		Source: "custom",
		Stream: stream,
	})
	c.Assert(m, gc.DeepEquals, s.expected)
}
func (s *funcSuite) TestParseMetadataDefaultStream(c *gc.C) {
	m, err := imagemetadata.ParseMetadataFromParams(s.api, params.CloudImageMetadata{}, s.env)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(m, gc.DeepEquals, s.expected)
}
func (s *funcSuite) TestParseMetadataAnySource(c *gc.C) {
	s.expected.Source = "any"
	m, err := imagemetadata.ParseMetadataFromParams(s.api, params.CloudImageMetadata{Source: "any"}, s.env)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(m, gc.DeepEquals, s.expected)
}
Exemple #8
0
func (s *funcSuite) TestParseMetadataDefaultStream(c *gc.C) {
	m := imagemetadata.ParseMetadataFromParams(params.CloudImageMetadata{
		Source: "custom",
	})
	c.Assert(m, gc.DeepEquals, s.expected)
}
Exemple #9
0
func (s *funcSuite) TestParseMetadataSourcePanic(c *gc.C) {
	m := func() { imagemetadata.ParseMetadataFromParams(params.CloudImageMetadata{}) }
	c.Assert(m, gc.PanicMatches, `unknown cloud image metadata source ""`)
}