Browse code

remove testify asserts from pkg/discovery

Signed-off-by: Morgan Bauer <mbauer@us.ibm.com>

Morgan Bauer authored on 2015/10/02 09:02:38
Showing 5 changed files
... ...
@@ -3,92 +3,103 @@ package discovery
3 3
 import (
4 4
 	"testing"
5 5
 
6
-	"github.com/stretchr/testify/assert"
6
+	"github.com/go-check/check"
7 7
 )
8 8
 
9
-func TestNewEntry(t *testing.T) {
9
+// Hook up gocheck into the "go test" runner.
10
+func Test(t *testing.T) { check.TestingT(t) }
11
+
12
+type DiscoverySuite struct{}
13
+
14
+var _ = check.Suite(&DiscoverySuite{})
15
+
16
+func (s *DiscoverySuite) TestNewEntry(c *check.C) {
10 17
 	entry, err := NewEntry("127.0.0.1:2375")
11
-	assert.NoError(t, err)
12
-	assert.True(t, entry.Equals(&Entry{Host: "127.0.0.1", Port: "2375"}))
13
-	assert.Equal(t, entry.String(), "127.0.0.1:2375")
18
+	c.Assert(err, check.IsNil)
19
+	c.Assert(entry.Equals(&Entry{Host: "127.0.0.1", Port: "2375"}), check.Equals, true)
20
+	c.Assert(entry.String(), check.Equals, "127.0.0.1:2375")
14 21
 
15 22
 	_, err = NewEntry("127.0.0.1")
16
-	assert.Error(t, err)
23
+	c.Assert(err, check.NotNil)
17 24
 }
18 25
 
19
-func TestParse(t *testing.T) {
26
+func (s *DiscoverySuite) TestParse(c *check.C) {
20 27
 	scheme, uri := parse("127.0.0.1:2375")
21
-	assert.Equal(t, scheme, "nodes")
22
-	assert.Equal(t, uri, "127.0.0.1:2375")
28
+	c.Assert(scheme, check.Equals, "nodes")
29
+	c.Assert(uri, check.Equals, "127.0.0.1:2375")
23 30
 
24 31
 	scheme, uri = parse("localhost:2375")
25
-	assert.Equal(t, scheme, "nodes")
26
-	assert.Equal(t, uri, "localhost:2375")
32
+	c.Assert(scheme, check.Equals, "nodes")
33
+	c.Assert(uri, check.Equals, "localhost:2375")
27 34
 
28 35
 	scheme, uri = parse("scheme://127.0.0.1:2375")
29
-	assert.Equal(t, scheme, "scheme")
30
-	assert.Equal(t, uri, "127.0.0.1:2375")
36
+	c.Assert(scheme, check.Equals, "scheme")
37
+	c.Assert(uri, check.Equals, "127.0.0.1:2375")
31 38
 
32 39
 	scheme, uri = parse("scheme://localhost:2375")
33
-	assert.Equal(t, scheme, "scheme")
34
-	assert.Equal(t, uri, "localhost:2375")
40
+	c.Assert(scheme, check.Equals, "scheme")
41
+	c.Assert(uri, check.Equals, "localhost:2375")
35 42
 
36 43
 	scheme, uri = parse("")
37
-	assert.Equal(t, scheme, "nodes")
38
-	assert.Equal(t, uri, "")
44
+	c.Assert(scheme, check.Equals, "nodes")
45
+	c.Assert(uri, check.Equals, "")
39 46
 }
40 47
 
41
-func TestCreateEntries(t *testing.T) {
48
+func (s *DiscoverySuite) TestCreateEntries(c *check.C) {
42 49
 	entries, err := CreateEntries(nil)
43
-	assert.Equal(t, entries, Entries{})
44
-	assert.NoError(t, err)
50
+	c.Assert(entries, check.DeepEquals, Entries{})
51
+	c.Assert(err, check.IsNil)
45 52
 
46 53
 	entries, err = CreateEntries([]string{"127.0.0.1:2375", "127.0.0.2:2375", ""})
47
-	assert.NoError(t, err)
54
+	c.Assert(err, check.IsNil)
48 55
 	expected := Entries{
49 56
 		&Entry{Host: "127.0.0.1", Port: "2375"},
50 57
 		&Entry{Host: "127.0.0.2", Port: "2375"},
51 58
 	}
52
-	assert.True(t, entries.Equals(expected))
59
+	c.Assert(entries.Equals(expected), check.Equals, true)
53 60
 
54 61
 	_, err = CreateEntries([]string{"127.0.0.1", "127.0.0.2"})
55
-	assert.Error(t, err)
62
+	c.Assert(err, check.NotNil)
56 63
 }
57 64
 
58
-func TestContainsEntry(t *testing.T) {
65
+func (s *DiscoverySuite) TestContainsEntry(c *check.C) {
59 66
 	entries, err := CreateEntries([]string{"127.0.0.1:2375", "127.0.0.2:2375", ""})
60
-	assert.NoError(t, err)
61
-	assert.True(t, entries.Contains(&Entry{Host: "127.0.0.1", Port: "2375"}))
62
-	assert.False(t, entries.Contains(&Entry{Host: "127.0.0.3", Port: "2375"}))
67
+	c.Assert(err, check.IsNil)
68
+	c.Assert(entries.Contains(&Entry{Host: "127.0.0.1", Port: "2375"}), check.Equals, true)
69
+	c.Assert(entries.Contains(&Entry{Host: "127.0.0.3", Port: "2375"}), check.Equals, false)
63 70
 }
64 71
 
65
-func TestEntriesEquality(t *testing.T) {
72
+func (s *DiscoverySuite) TestEntriesEquality(c *check.C) {
66 73
 	entries := Entries{
67 74
 		&Entry{Host: "127.0.0.1", Port: "2375"},
68 75
 		&Entry{Host: "127.0.0.2", Port: "2375"},
69 76
 	}
70 77
 
71 78
 	// Same
72
-	assert.True(t, entries.Equals(Entries{
79
+	c.Assert(entries.Equals(Entries{
73 80
 		&Entry{Host: "127.0.0.1", Port: "2375"},
74 81
 		&Entry{Host: "127.0.0.2", Port: "2375"},
75
-	}))
82
+	}), check.
83
+		Equals, true)
76 84
 
77 85
 	// Different size
78
-	assert.False(t, entries.Equals(Entries{
86
+	c.Assert(entries.Equals(Entries{
79 87
 		&Entry{Host: "127.0.0.1", Port: "2375"},
80 88
 		&Entry{Host: "127.0.0.2", Port: "2375"},
81 89
 		&Entry{Host: "127.0.0.3", Port: "2375"},
82
-	}))
90
+	}), check.
91
+		Equals, false)
83 92
 
84 93
 	// Different content
85
-	assert.False(t, entries.Equals(Entries{
94
+	c.Assert(entries.Equals(Entries{
86 95
 		&Entry{Host: "127.0.0.1", Port: "2375"},
87 96
 		&Entry{Host: "127.0.0.42", Port: "2375"},
88
-	}))
97
+	}), check.
98
+		Equals, false)
99
+
89 100
 }
90 101
 
91
-func TestEntriesDiff(t *testing.T) {
102
+func (s *DiscoverySuite) TestEntriesDiff(c *check.C) {
92 103
 	entry1 := &Entry{Host: "1.1.1.1", Port: "1111"}
93 104
 	entry2 := &Entry{Host: "2.2.2.2", Port: "2222"}
94 105
 	entry3 := &Entry{Host: "3.3.3.3", Port: "3333"}
... ...
@@ -96,25 +107,25 @@ func TestEntriesDiff(t *testing.T) {
96 96
 
97 97
 	// No diff
98 98
 	added, removed := entries.Diff(Entries{entry2, entry1})
99
-	assert.Empty(t, added)
100
-	assert.Empty(t, removed)
99
+	c.Assert(added, check.HasLen, 0)
100
+	c.Assert(removed, check.HasLen, 0)
101 101
 
102 102
 	// Add
103 103
 	added, removed = entries.Diff(Entries{entry2, entry3, entry1})
104
-	assert.Len(t, added, 1)
105
-	assert.True(t, added.Contains(entry3))
106
-	assert.Empty(t, removed)
104
+	c.Assert(added, check.HasLen, 1)
105
+	c.Assert(added.Contains(entry3), check.Equals, true)
106
+	c.Assert(removed, check.HasLen, 0)
107 107
 
108 108
 	// Remove
109 109
 	added, removed = entries.Diff(Entries{entry2})
110
-	assert.Empty(t, added)
111
-	assert.Len(t, removed, 1)
112
-	assert.True(t, removed.Contains(entry1))
110
+	c.Assert(added, check.HasLen, 0)
111
+	c.Assert(removed, check.HasLen, 1)
112
+	c.Assert(removed.Contains(entry1), check.Equals, true)
113 113
 
114 114
 	// Add and remove
115 115
 	added, removed = entries.Diff(Entries{entry1, entry3})
116
-	assert.Len(t, added, 1)
117
-	assert.True(t, added.Contains(entry3))
118
-	assert.Len(t, removed, 1)
119
-	assert.True(t, removed.Contains(entry2))
116
+	c.Assert(added, check.HasLen, 1)
117
+	c.Assert(added.Contains(entry3), check.Equals, true)
118
+	c.Assert(removed, check.HasLen, 1)
119
+	c.Assert(removed.Contains(entry2), check.Equals, true)
120 120
 }
... ...
@@ -6,41 +6,49 @@ import (
6 6
 	"testing"
7 7
 
8 8
 	"github.com/docker/docker/pkg/discovery"
9
-	"github.com/stretchr/testify/assert"
9
+
10
+	"github.com/go-check/check"
10 11
 )
11 12
 
12
-func TestInitialize(t *testing.T) {
13
+// Hook up gocheck into the "go test" runner.
14
+func Test(t *testing.T) { check.TestingT(t) }
15
+
16
+type DiscoverySuite struct{}
17
+
18
+var _ = check.Suite(&DiscoverySuite{})
19
+
20
+func (s *DiscoverySuite) TestInitialize(c *check.C) {
13 21
 	d := &Discovery{}
14 22
 	d.Initialize("/path/to/file", 1000, 0)
15
-	assert.Equal(t, d.path, "/path/to/file")
23
+	c.Assert(d.path, check.Equals, "/path/to/file")
16 24
 }
17 25
 
18
-func TestNew(t *testing.T) {
26
+func (s *DiscoverySuite) TestNew(c *check.C) {
19 27
 	d, err := discovery.New("file:///path/to/file", 0, 0)
20
-	assert.NoError(t, err)
21
-	assert.Equal(t, d.(*Discovery).path, "/path/to/file")
28
+	c.Assert(err, check.IsNil)
29
+	c.Assert(d.(*Discovery).path, check.Equals, "/path/to/file")
22 30
 }
23 31
 
24
-func TestContent(t *testing.T) {
32
+func (s *DiscoverySuite) TestContent(c *check.C) {
25 33
 	data := `
26 34
 1.1.1.[1:2]:1111
27 35
 2.2.2.[2:4]:2222
28 36
 `
29 37
 	ips := parseFileContent([]byte(data))
30
-	assert.Len(t, ips, 5)
31
-	assert.Equal(t, ips[0], "1.1.1.1:1111")
32
-	assert.Equal(t, ips[1], "1.1.1.2:1111")
33
-	assert.Equal(t, ips[2], "2.2.2.2:2222")
34
-	assert.Equal(t, ips[3], "2.2.2.3:2222")
35
-	assert.Equal(t, ips[4], "2.2.2.4:2222")
38
+	c.Assert(ips, check.HasLen, 5)
39
+	c.Assert(ips[0], check.Equals, "1.1.1.1:1111")
40
+	c.Assert(ips[1], check.Equals, "1.1.1.2:1111")
41
+	c.Assert(ips[2], check.Equals, "2.2.2.2:2222")
42
+	c.Assert(ips[3], check.Equals, "2.2.2.3:2222")
43
+	c.Assert(ips[4], check.Equals, "2.2.2.4:2222")
36 44
 }
37 45
 
38
-func TestRegister(t *testing.T) {
46
+func (s *DiscoverySuite) TestRegister(c *check.C) {
39 47
 	discovery := &Discovery{path: "/path/to/file"}
40
-	assert.Error(t, discovery.Register("0.0.0.0"))
48
+	c.Assert(discovery.Register("0.0.0.0"), check.NotNil)
41 49
 }
42 50
 
43
-func TestParsingContentsWithComments(t *testing.T) {
51
+func (s *DiscoverySuite) TestParsingContentsWithComments(c *check.C) {
44 52
 	data := `
45 53
 ### test ###
46 54
 1.1.1.1:1111 # inline comment
... ...
@@ -50,12 +58,12 @@ func TestParsingContentsWithComments(t *testing.T) {
50 50
 ### test ###
51 51
 `
52 52
 	ips := parseFileContent([]byte(data))
53
-	assert.Len(t, ips, 2)
54
-	assert.Equal(t, "1.1.1.1:1111", ips[0])
55
-	assert.Equal(t, "3.3.3.3:3333", ips[1])
53
+	c.Assert(ips, check.HasLen, 2)
54
+	c.Assert("1.1.1.1:1111", check.Equals, ips[0])
55
+	c.Assert("3.3.3.3:3333", check.Equals, ips[1])
56 56
 }
57 57
 
58
-func TestWatch(t *testing.T) {
58
+func (s *DiscoverySuite) TestWatch(c *check.C) {
59 59
 	data := `
60 60
 1.1.1.1:1111
61 61
 2.2.2.2:2222
... ...
@@ -67,9 +75,9 @@ func TestWatch(t *testing.T) {
67 67
 
68 68
 	// Create a temporary file and remove it.
69 69
 	tmp, err := ioutil.TempFile(os.TempDir(), "discovery-file-test")
70
-	assert.NoError(t, err)
71
-	assert.NoError(t, tmp.Close())
72
-	assert.NoError(t, os.Remove(tmp.Name()))
70
+	c.Assert(err, check.IsNil)
71
+	c.Assert(tmp.Close(), check.IsNil)
72
+	c.Assert(os.Remove(tmp.Name()), check.IsNil)
73 73
 
74 74
 	// Set up file discovery.
75 75
 	d := &Discovery{}
... ...
@@ -78,7 +86,7 @@ func TestWatch(t *testing.T) {
78 78
 	ch, errCh := d.Watch(stopCh)
79 79
 
80 80
 	// Make sure it fires errors since the file doesn't exist.
81
-	assert.Error(t, <-errCh)
81
+	c.Assert(<-errCh, check.NotNil)
82 82
 	// We have to drain the error channel otherwise Watch will get stuck.
83 83
 	go func() {
84 84
 		for range errCh {
... ...
@@ -86,21 +94,21 @@ func TestWatch(t *testing.T) {
86 86
 	}()
87 87
 
88 88
 	// Write the file and make sure we get the expected value back.
89
-	assert.NoError(t, ioutil.WriteFile(tmp.Name(), []byte(data), 0600))
90
-	assert.Equal(t, expected, <-ch)
89
+	c.Assert(ioutil.WriteFile(tmp.Name(), []byte(data), 0600), check.IsNil)
90
+	c.Assert(<-ch, check.DeepEquals, expected)
91 91
 
92 92
 	// Add a new entry and look it up.
93 93
 	expected = append(expected, &discovery.Entry{Host: "3.3.3.3", Port: "3333"})
94 94
 	f, err := os.OpenFile(tmp.Name(), os.O_APPEND|os.O_WRONLY, 0600)
95
-	assert.NoError(t, err)
96
-	assert.NotNil(t, f)
95
+	c.Assert(err, check.IsNil)
96
+	c.Assert(f, check.NotNil)
97 97
 	_, err = f.WriteString("\n3.3.3.3:3333\n")
98
-	assert.NoError(t, err)
98
+	c.Assert(err, check.IsNil)
99 99
 	f.Close()
100
-	assert.Equal(t, expected, <-ch)
100
+	c.Assert(<-ch, check.DeepEquals, expected)
101 101
 
102 102
 	// Stop and make sure it closes all channels.
103 103
 	close(stopCh)
104
-	assert.Nil(t, <-ch)
105
-	assert.Nil(t, <-errCh)
104
+	c.Assert(<-ch, check.IsNil)
105
+	c.Assert(<-errCh, check.IsNil)
106 106
 }
... ...
@@ -1,55 +1,53 @@
1 1
 package discovery
2 2
 
3 3
 import (
4
-	"testing"
5
-
6
-	"github.com/stretchr/testify/assert"
4
+	"github.com/go-check/check"
7 5
 )
8 6
 
9
-func TestGeneratorNotGenerate(t *testing.T) {
7
+func (s *DiscoverySuite) TestGeneratorNotGenerate(c *check.C) {
10 8
 	ips := Generate("127.0.0.1")
11
-	assert.Equal(t, len(ips), 1)
12
-	assert.Equal(t, ips[0], "127.0.0.1")
9
+	c.Assert(len(ips), check.Equals, 1)
10
+	c.Assert(ips[0], check.Equals, "127.0.0.1")
13 11
 }
14 12
 
15
-func TestGeneratorWithPortNotGenerate(t *testing.T) {
13
+func (s *DiscoverySuite) TestGeneratorWithPortNotGenerate(c *check.C) {
16 14
 	ips := Generate("127.0.0.1:8080")
17
-	assert.Equal(t, len(ips), 1)
18
-	assert.Equal(t, ips[0], "127.0.0.1:8080")
15
+	c.Assert(len(ips), check.Equals, 1)
16
+	c.Assert(ips[0], check.Equals, "127.0.0.1:8080")
19 17
 }
20 18
 
21
-func TestGeneratorMatchFailedNotGenerate(t *testing.T) {
19
+func (s *DiscoverySuite) TestGeneratorMatchFailedNotGenerate(c *check.C) {
22 20
 	ips := Generate("127.0.0.[1]")
23
-	assert.Equal(t, len(ips), 1)
24
-	assert.Equal(t, ips[0], "127.0.0.[1]")
21
+	c.Assert(len(ips), check.Equals, 1)
22
+	c.Assert(ips[0], check.Equals, "127.0.0.[1]")
25 23
 }
26 24
 
27
-func TestGeneratorWithPort(t *testing.T) {
25
+func (s *DiscoverySuite) TestGeneratorWithPort(c *check.C) {
28 26
 	ips := Generate("127.0.0.[1:11]:2375")
29
-	assert.Equal(t, len(ips), 11)
30
-	assert.Equal(t, ips[0], "127.0.0.1:2375")
31
-	assert.Equal(t, ips[1], "127.0.0.2:2375")
32
-	assert.Equal(t, ips[2], "127.0.0.3:2375")
33
-	assert.Equal(t, ips[3], "127.0.0.4:2375")
34
-	assert.Equal(t, ips[4], "127.0.0.5:2375")
35
-	assert.Equal(t, ips[5], "127.0.0.6:2375")
36
-	assert.Equal(t, ips[6], "127.0.0.7:2375")
37
-	assert.Equal(t, ips[7], "127.0.0.8:2375")
38
-	assert.Equal(t, ips[8], "127.0.0.9:2375")
39
-	assert.Equal(t, ips[9], "127.0.0.10:2375")
40
-	assert.Equal(t, ips[10], "127.0.0.11:2375")
27
+	c.Assert(len(ips), check.Equals, 11)
28
+	c.Assert(ips[0], check.Equals, "127.0.0.1:2375")
29
+	c.Assert(ips[1], check.Equals, "127.0.0.2:2375")
30
+	c.Assert(ips[2], check.Equals, "127.0.0.3:2375")
31
+	c.Assert(ips[3], check.Equals, "127.0.0.4:2375")
32
+	c.Assert(ips[4], check.Equals, "127.0.0.5:2375")
33
+	c.Assert(ips[5], check.Equals, "127.0.0.6:2375")
34
+	c.Assert(ips[6], check.Equals, "127.0.0.7:2375")
35
+	c.Assert(ips[7], check.Equals, "127.0.0.8:2375")
36
+	c.Assert(ips[8], check.Equals, "127.0.0.9:2375")
37
+	c.Assert(ips[9], check.Equals, "127.0.0.10:2375")
38
+	c.Assert(ips[10], check.Equals, "127.0.0.11:2375")
41 39
 }
42 40
 
43
-func TestGenerateWithMalformedInputAtRangeStart(t *testing.T) {
41
+func (s *DiscoverySuite) TestGenerateWithMalformedInputAtRangeStart(c *check.C) {
44 42
 	malformedInput := "127.0.0.[x:11]:2375"
45 43
 	ips := Generate(malformedInput)
46
-	assert.Equal(t, len(ips), 1)
47
-	assert.Equal(t, ips[0], malformedInput)
44
+	c.Assert(len(ips), check.Equals, 1)
45
+	c.Assert(ips[0], check.Equals, malformedInput)
48 46
 }
49 47
 
50
-func TestGenerateWithMalformedInputAtRangeEnd(t *testing.T) {
48
+func (s *DiscoverySuite) TestGenerateWithMalformedInputAtRangeEnd(c *check.C) {
51 49
 	malformedInput := "127.0.0.[1:x]:2375"
52 50
 	ips := Generate(malformedInput)
53
-	assert.Equal(t, len(ips), 1)
54
-	assert.Equal(t, ips[0], malformedInput)
51
+	c.Assert(len(ips), check.Equals, 1)
52
+	c.Assert(ips[0], check.Equals, malformedInput)
55 53
 }
... ...
@@ -9,58 +9,66 @@ import (
9 9
 	"github.com/docker/docker/pkg/discovery"
10 10
 	"github.com/docker/libkv/store"
11 11
 	libkvmock "github.com/docker/libkv/store/mock"
12
-	"github.com/stretchr/testify/assert"
13 12
 	"github.com/stretchr/testify/mock"
13
+
14
+	"github.com/go-check/check"
14 15
 )
15 16
 
16
-func TestInitialize(t *testing.T) {
17
+// Hook up gocheck into the "go test" runner.
18
+func Test(t *testing.T) { check.TestingT(t) }
19
+
20
+type DiscoverySuite struct{}
21
+
22
+var _ = check.Suite(&DiscoverySuite{})
23
+
24
+func (ds *DiscoverySuite) TestInitialize(c *check.C) {
17 25
 	storeMock, err := libkvmock.New([]string{"127.0.0.1"}, nil)
18
-	assert.NotNil(t, storeMock)
19
-	assert.NoError(t, err)
26
+	c.Assert(storeMock, check.NotNil)
27
+	c.Assert(err, check.IsNil)
20 28
 
21 29
 	d := &Discovery{backend: store.CONSUL}
22 30
 	d.Initialize("127.0.0.1", 0, 0)
23 31
 	d.store = storeMock
24 32
 
25 33
 	s := d.store.(*libkvmock.Mock)
26
-	assert.Len(t, s.Endpoints, 1)
27
-	assert.Equal(t, s.Endpoints[0], "127.0.0.1")
28
-	assert.Equal(t, d.path, discoveryPath)
34
+	c.Assert(s.Endpoints, check.HasLen, 1)
35
+	c.Assert(s.Endpoints[0], check.Equals, "127.0.0.1")
36
+	c.Assert(d.path, check.Equals, discoveryPath)
29 37
 
30 38
 	storeMock, err = libkvmock.New([]string{"127.0.0.1:1234"}, nil)
31
-	assert.NotNil(t, storeMock)
32
-	assert.NoError(t, err)
39
+	c.Assert(storeMock, check.NotNil)
40
+	c.Assert(err, check.IsNil)
33 41
 
34 42
 	d = &Discovery{backend: store.CONSUL}
35 43
 	d.Initialize("127.0.0.1:1234/path", 0, 0)
36 44
 	d.store = storeMock
37 45
 
38 46
 	s = d.store.(*libkvmock.Mock)
39
-	assert.Len(t, s.Endpoints, 1)
40
-	assert.Equal(t, s.Endpoints[0], "127.0.0.1:1234")
41
-	assert.Equal(t, d.path, "path/"+discoveryPath)
47
+	c.Assert(s.Endpoints, check.HasLen, 1)
48
+	c.Assert(s.Endpoints[0], check.Equals, "127.0.0.1:1234")
49
+	c.Assert(d.path, check.Equals, "path/"+discoveryPath)
42 50
 
43 51
 	storeMock, err = libkvmock.New([]string{"127.0.0.1:1234", "127.0.0.2:1234", "127.0.0.3:1234"}, nil)
44
-	assert.NotNil(t, storeMock)
45
-	assert.NoError(t, err)
52
+	c.Assert(storeMock, check.NotNil)
53
+	c.Assert(err, check.IsNil)
46 54
 
47 55
 	d = &Discovery{backend: store.CONSUL}
48 56
 	d.Initialize("127.0.0.1:1234,127.0.0.2:1234,127.0.0.3:1234/path", 0, 0)
49 57
 	d.store = storeMock
50 58
 
51 59
 	s = d.store.(*libkvmock.Mock)
52
-	if assert.Len(t, s.Endpoints, 3) {
53
-		assert.Equal(t, s.Endpoints[0], "127.0.0.1:1234")
54
-		assert.Equal(t, s.Endpoints[1], "127.0.0.2:1234")
55
-		assert.Equal(t, s.Endpoints[2], "127.0.0.3:1234")
56
-	}
57
-	assert.Equal(t, d.path, "path/"+discoveryPath)
60
+	c.Assert(s.Endpoints, check.HasLen, 3)
61
+	c.Assert(s.Endpoints[0], check.Equals, "127.0.0.1:1234")
62
+	c.Assert(s.Endpoints[1], check.Equals, "127.0.0.2:1234")
63
+	c.Assert(s.Endpoints[2], check.Equals, "127.0.0.3:1234")
64
+
65
+	c.Assert(d.path, check.Equals, "path/"+discoveryPath)
58 66
 }
59 67
 
60
-func TestWatch(t *testing.T) {
68
+func (ds *DiscoverySuite) TestWatch(c *check.C) {
61 69
 	storeMock, err := libkvmock.New([]string{"127.0.0.1:1234"}, nil)
62
-	assert.NotNil(t, storeMock)
63
-	assert.NoError(t, err)
70
+	c.Assert(storeMock, check.NotNil)
71
+	c.Assert(err, check.IsNil)
64 72
 
65 73
 	d := &Discovery{backend: store.CONSUL}
66 74
 	d.Initialize("127.0.0.1:1234/path", 0, 0)
... ...
@@ -86,7 +94,7 @@ func TestWatch(t *testing.T) {
86 86
 	ch, errCh := d.Watch(stopCh)
87 87
 
88 88
 	// It should fire an error since the first WatchTree call failed.
89
-	assert.EqualError(t, <-errCh, "test error")
89
+	c.Assert(<-errCh, check.ErrorMatches, "test error")
90 90
 	// We have to drain the error channel otherwise Watch will get stuck.
91 91
 	go func() {
92 92
 		for range errCh {
... ...
@@ -95,13 +103,13 @@ func TestWatch(t *testing.T) {
95 95
 
96 96
 	// Push the entries into the store channel and make sure discovery emits.
97 97
 	mockCh <- kvs
98
-	assert.Equal(t, <-ch, expected)
98
+	c.Assert(<-ch, check.DeepEquals, expected)
99 99
 
100 100
 	// Add a new entry.
101 101
 	expected = append(expected, &discovery.Entry{Host: "3.3.3.3", Port: "3333"})
102 102
 	kvs = append(kvs, &store.KVPair{Key: path.Join("path", discoveryPath, "3.3.3.3"), Value: []byte("3.3.3.3:3333")})
103 103
 	mockCh <- kvs
104
-	assert.Equal(t, <-ch, expected)
104
+	c.Assert(<-ch, check.DeepEquals, expected)
105 105
 
106 106
 	// Make sure that if an error occurs it retries.
107 107
 	// This third call to WatchTree will be checked later by AssertExpectations.
... ...
@@ -112,8 +120,8 @@ func TestWatch(t *testing.T) {
112 112
 
113 113
 	// Stop and make sure it closes all channels.
114 114
 	close(stopCh)
115
-	assert.Nil(t, <-ch)
116
-	assert.Nil(t, <-errCh)
115
+	c.Assert(<-ch, check.IsNil)
116
+	c.Assert(<-errCh, check.IsNil)
117 117
 
118
-	s.AssertExpectations(t)
118
+	s.AssertExpectations(c)
119 119
 }
... ...
@@ -4,29 +4,37 @@ import (
4 4
 	"testing"
5 5
 
6 6
 	"github.com/docker/docker/pkg/discovery"
7
-	"github.com/stretchr/testify/assert"
7
+
8
+	"github.com/go-check/check"
8 9
 )
9 10
 
10
-func TestInitialize(t *testing.T) {
11
+// Hook up gocheck into the "go test" runner.
12
+func Test(t *testing.T) { check.TestingT(t) }
13
+
14
+type DiscoverySuite struct{}
15
+
16
+var _ = check.Suite(&DiscoverySuite{})
17
+
18
+func (s *DiscoverySuite) TestInitialize(c *check.C) {
11 19
 	d := &Discovery{}
12 20
 	d.Initialize("1.1.1.1:1111,2.2.2.2:2222", 0, 0)
13
-	assert.Equal(t, len(d.entries), 2)
14
-	assert.Equal(t, d.entries[0].String(), "1.1.1.1:1111")
15
-	assert.Equal(t, d.entries[1].String(), "2.2.2.2:2222")
21
+	c.Assert(len(d.entries), check.Equals, 2)
22
+	c.Assert(d.entries[0].String(), check.Equals, "1.1.1.1:1111")
23
+	c.Assert(d.entries[1].String(), check.Equals, "2.2.2.2:2222")
16 24
 }
17 25
 
18
-func TestInitializeWithPattern(t *testing.T) {
26
+func (s *DiscoverySuite) TestInitializeWithPattern(c *check.C) {
19 27
 	d := &Discovery{}
20 28
 	d.Initialize("1.1.1.[1:2]:1111,2.2.2.[2:4]:2222", 0, 0)
21
-	assert.Equal(t, len(d.entries), 5)
22
-	assert.Equal(t, d.entries[0].String(), "1.1.1.1:1111")
23
-	assert.Equal(t, d.entries[1].String(), "1.1.1.2:1111")
24
-	assert.Equal(t, d.entries[2].String(), "2.2.2.2:2222")
25
-	assert.Equal(t, d.entries[3].String(), "2.2.2.3:2222")
26
-	assert.Equal(t, d.entries[4].String(), "2.2.2.4:2222")
29
+	c.Assert(len(d.entries), check.Equals, 5)
30
+	c.Assert(d.entries[0].String(), check.Equals, "1.1.1.1:1111")
31
+	c.Assert(d.entries[1].String(), check.Equals, "1.1.1.2:1111")
32
+	c.Assert(d.entries[2].String(), check.Equals, "2.2.2.2:2222")
33
+	c.Assert(d.entries[3].String(), check.Equals, "2.2.2.3:2222")
34
+	c.Assert(d.entries[4].String(), check.Equals, "2.2.2.4:2222")
27 35
 }
28 36
 
29
-func TestWatch(t *testing.T) {
37
+func (s *DiscoverySuite) TestWatch(c *check.C) {
30 38
 	d := &Discovery{}
31 39
 	d.Initialize("1.1.1.1:1111,2.2.2.2:2222", 0, 0)
32 40
 	expected := discovery.Entries{
... ...
@@ -34,10 +42,10 @@ func TestWatch(t *testing.T) {
34 34
 		&discovery.Entry{Host: "2.2.2.2", Port: "2222"},
35 35
 	}
36 36
 	ch, _ := d.Watch(nil)
37
-	assert.True(t, expected.Equals(<-ch))
37
+	c.Assert(expected.Equals(<-ch), check.Equals, true)
38 38
 }
39 39
 
40
-func TestRegister(t *testing.T) {
40
+func (s *DiscoverySuite) TestRegister(c *check.C) {
41 41
 	d := &Discovery{}
42
-	assert.Error(t, d.Register("0.0.0.0"))
42
+	c.Assert(d.Register("0.0.0.0"), check.NotNil)
43 43
 }