github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/instance/testing/instance.go (about)

     1  // Copyright 2013 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package testing
     5  
     6  import (
     7  	gc "gopkg.in/check.v1"
     8  
     9  	"github.com/juju/juju/instance"
    10  )
    11  
    12  // MatchInstances uses DeepEquals to check the instances returned.  The lists
    13  // are first put into a map, so the ordering of the result and expected values
    14  // is not tested, and duplicates are ignored.
    15  func MatchInstances(c *gc.C, result []instance.Instance, expected ...instance.Instance) {
    16  	resultMap := make(map[instance.Id]instance.Instance)
    17  	for _, i := range result {
    18  		resultMap[i.Id()] = i
    19  	}
    20  
    21  	expectedMap := make(map[instance.Id]instance.Instance)
    22  	for _, i := range expected {
    23  		expectedMap[i.Id()] = i
    24  	}
    25  	c.Assert(resultMap, gc.DeepEquals, expectedMap)
    26  }