Skip to content

Commit

Permalink
Merge pull request #1384 from anastasiamac/set-annotations-Bug1409141
Browse files Browse the repository at this point in the history
Changed test to ignore the order of returned collection.

Test was failing because expected collection and obtained collection contained elements in different order. Since the order of elements is not important for the test, changed it to examine contents instead.


(Review request: http://reviews.vapour.ws/r/706/)
  • Loading branch information
jujubot committed Jan 9, 2015
2 parents 7044982 + b29a8b2 commit 66bf416
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions api/annotations/client_test.go
Expand Up @@ -26,33 +26,35 @@ func (s *annotationsMockSuite) TestSetEntitiesAnnotation(c *gc.C) {
var called bool
annts := map[string]string{"annotation1": "test"}
annts2 := map[string]string{"annotation2": "test"}
setParams := map[string]map[string]string{
"charmA": annts,
"serviceB": annts2,
}
apiCaller := basetesting.APICallerFunc(
func(
objType string,
func(objType string,
version int,
id, request string,
a, result interface{}) error {
a, result interface{},
) error {
called = true
c.Check(objType, gc.Equals, "Annotations")
c.Check(id, gc.Equals, "")
c.Check(request, gc.Equals, "Set")

args, ok := a.(params.AnnotationsSet)
c.Assert(ok, jc.IsTrue)
expected := params.AnnotationsSet{
Annotations: []params.EntityAnnotations{
{Entity: params.Entity{"charmA"}, Annotations: annts},
{Entity: params.Entity{"serviceB"}, Annotations: annts2},
}}
c.Assert(args, gc.DeepEquals, expected)

for _, aParam := range args.Annotations {
// Since sometimes arrays returned on some
// architectures vary the order within params.AnnotationsSet,
// simply assert that each entity has its own annotations.
// Bug 1409141
c.Assert(aParam.Annotations, gc.DeepEquals, setParams[aParam.Entity.Tag])
}
return nil
})
annotationsClient := annotations.NewClient(apiCaller)
err := annotationsClient.Set(
map[string]map[string]string{
"charmA": annts,
"serviceB": annts2,
})
err := annotationsClient.Set(setParams)
c.Assert(err, jc.ErrorIsNil)
c.Assert(called, jc.IsTrue)
}
Expand Down

0 comments on commit 66bf416

Please sign in to comment.