Merge lp:~dave-cheney/juju-core/101-lp-1152202 into lp:~juju/juju-core/trunk

Proposed by Dave Cheney
Status: Merged
Merged at revision: 989
Proposed branch: lp:~dave-cheney/juju-core/101-lp-1152202
Merge into: lp:~juju/juju-core/trunk
Diff against target: 32 lines (+14/-1)
1 file modified
environs/jujutest/tests.go (+14/-1)
To merge this branch: bzr merge lp:~dave-cheney/juju-core/101-lp-1152202
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+152192@code.launchpad.net

Description of the change

environs/jujutest: always sort during checkList

Fix LP#1152202 by sorting the arrays to compare inside checkList. This is a temporary fix until I can get an SliceEquals checker added to gocheck.

https://codereview.appspot.com/7551046/

To post a comment you must log in.
Revision history for this message
Dimiter Naydenov (dimitern) wrote :

Thanks, LGTM! Very nice, we definitely need this in gocheck!

https://codereview.appspot.com/7551046/

Revision history for this message
William Reade (fwereade) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'environs/jujutest/tests.go'
2--- environs/jujutest/tests.go 2013-03-07 15:06:37 +0000
3+++ environs/jujutest/tests.go 2013-03-08 22:27:21 +0000
4@@ -11,6 +11,7 @@
5 coretesting "launchpad.net/juju-core/testing"
6 "launchpad.net/juju-core/trivial"
7 "net/http"
8+ "sort"
9 )
10
11 // Tests is a gocheck suite containing tests verifying juju functionality
12@@ -186,7 +187,19 @@
13 func checkList(c *C, storage environs.StorageReader, prefix string, names []string) {
14 lnames, err := storage.List(prefix)
15 c.Assert(err, IsNil)
16- c.Assert(lnames, DeepEquals, names)
17+ // TODO(dfc) gocheck should grow an SliceEquals checker.
18+ expected := copyslice(lnames)
19+ sort.Strings(expected)
20+ actual := copyslice(names)
21+ sort.Strings(actual)
22+ c.Assert(expected, DeepEquals, actual)
23+}
24+
25+// copyslice returns a copy of the slice
26+func copyslice(s []string) []string {
27+ r := make([]string, len(s))
28+ copy(r, s)
29+ return r
30 }
31
32 func checkPutFile(c *C, storage environs.StorageWriter, name string, contents []byte) {

Subscribers

People subscribed via source and target branches