~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/instance/testing/instance.go

  • Committer: Nicholas Skaggs
  • Date: 2016-10-24 20:56:05 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161024205605-z8lta0uvuhtxwzwl
Initi with beta15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
}