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