func (*simplestreamsSuite) TestHasCloudFindsMatchWithTrailingSlash(c *gc.C) { metadata := simplestreams.IndexMetadata{ Clouds: []simplestreams.CloudSpec{ {Region: "r1", Endpoint: "http://e1/"}, {Region: "r2", Endpoint: "http://e2"}, }, } spec := simplestreams.CloudSpec{Region: "r1", Endpoint: "http://e1"} c.Check(simplestreams.HasCloud(metadata, spec), jc.IsTrue) spec = simplestreams.CloudSpec{Region: "r1", Endpoint: "http://e1/"} c.Check(simplestreams.HasCloud(metadata, spec), jc.IsTrue) spec = simplestreams.CloudSpec{Region: "r2", Endpoint: "http://e2/"} c.Check(simplestreams.HasCloud(metadata, spec), jc.IsTrue) }
func (*simplestreamsSuite) TestHasCloudFindsMatch(c *gc.C) { metadata := simplestreams.IndexMetadata{ Clouds: []simplestreams.CloudSpec{ {Region: "r1", Endpoint: "http://e1"}, {Region: "r2", Endpoint: "http://e2"}, }, } c.Check(simplestreams.HasCloud(metadata, metadata.Clouds[1]), jc.IsTrue) }
func (*simplestreamsSuite) TestHasCloudReturnsFalseIfCloudsDoNotMatch(c *gc.C) { metadata := simplestreams.IndexMetadata{ Clouds: []simplestreams.CloudSpec{ {Region: "r1", Endpoint: "http://e1"}, {Region: "r2", Endpoint: "http://e2"}, }, } otherCloud := simplestreams.CloudSpec{Region: "r9", Endpoint: "http://e9"} c.Check(simplestreams.HasCloud(metadata, otherCloud), jc.IsFalse) }
func (*simplestreamsSuite) TestHasCloudRequiresIdenticalEndpoint(c *gc.C) { metadata := simplestreams.IndexMetadata{ Clouds: []simplestreams.CloudSpec{ {Region: "around", Endpoint: "http://nearby"}, }, } similarCloud := metadata.Clouds[0] similarCloud.Endpoint = "http://far" c.Assert(similarCloud, gc.Not(gc.Equals), metadata.Clouds[0]) c.Check(simplestreams.HasCloud(metadata, similarCloud), jc.IsFalse) }
func (*simplestreamsSuite) TestHasCloudAcceptsNil(c *gc.C) { metadata := simplestreams.IndexMetadata{Clouds: nil} c.Check(simplestreams.HasCloud(metadata, simplestreams.CloudSpec{}), jc.IsTrue) }