Browse code

Remove pkg/testutil/assert in favor of testify

I noticed that we're using a homegrown package for assertions. The
functions are extremely similar to testify, but with enough slight
differences to be confusing (for example, Equal takes its arguments in a
different order). We already vendor testify, and it's used in a few
places by tests.

I also found some problems with pkg/testutil/assert. For example, the
NotNil function seems to be broken. It checks the argument against
"nil", which only works for an interface. If you pass in a nil map or
slice, the equality check will fail.

In the interest of avoiding NIH, I'm proposing replacing
pkg/testutil/assert with testify. The test code looks almost the same,
but we avoid the confusion of having two similar but slightly different
assertion packages, and having to maintain our own package instead of
using a commonly-used one.

In the process, I found a few places where the tests should halt if an
assertion fails, so I've made those cases (that I noticed) use "require"
instead of "assert", and I've vendored the "require" package from
testify alongside the already-present "assert" package.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>

Aaron Lehmann authored on 2017/04/14 07:45:37
Showing 102 changed files
... ...
@@ -1,8 +1,9 @@
1 1
 package dockerfile
2 2
 
3 3
 import (
4
-	"github.com/docker/docker/pkg/testutil/assert"
5 4
 	"testing"
5
+
6
+	"github.com/stretchr/testify/assert"
6 7
 )
7 8
 
8 9
 func strPtr(source string) *string {
... ...
@@ -37,7 +38,7 @@ func TestGetAllAllowed(t *testing.T) {
37 37
 		"ArgFromMeta":                         "frommeta1",
38 38
 		"ArgFromMetaOverriden":                "fromdockerfile3",
39 39
 	}
40
-	assert.DeepEqual(t, all, expected)
40
+	assert.Equal(t, expected, all)
41 41
 }
42 42
 
43 43
 func TestGetAllMeta(t *testing.T) {
... ...
@@ -59,5 +60,5 @@ func TestGetAllMeta(t *testing.T) {
59 59
 		"ArgOverriddenByOptions":        "fromopt2",
60 60
 		"ArgNoDefaultInMetaFromOptions": "fromopt3",
61 61
 	}
62
-	assert.DeepEqual(t, all, expected)
62
+	assert.Equal(t, expected, all)
63 63
 }
... ...
@@ -5,13 +5,13 @@ import (
5 5
 	"testing"
6 6
 
7 7
 	"github.com/docker/docker/builder/dockerfile/parser"
8
-	"github.com/docker/docker/pkg/testutil/assert"
8
+	"github.com/stretchr/testify/assert"
9 9
 )
10 10
 
11 11
 func TestAddNodesForLabelOption(t *testing.T) {
12 12
 	dockerfile := "FROM scratch"
13 13
 	result, err := parser.Parse(strings.NewReader(dockerfile))
14
-	assert.NilError(t, err)
14
+	assert.NoError(t, err)
15 15
 
16 16
 	labels := map[string]string{
17 17
 		"org.e": "cli-e",
... ...
@@ -27,8 +27,8 @@ func TestAddNodesForLabelOption(t *testing.T) {
27 27
 		"FROM scratch",
28 28
 		`LABEL "org.a"='cli-a' "org.b"='cli-b' "org.c"='cli-c' "org.d"='cli-d' "org.e"='cli-e'`,
29 29
 	}
30
-	assert.Equal(t, len(nodes.Children), 2)
30
+	assert.Len(t, nodes.Children, 2)
31 31
 	for i, v := range nodes.Children {
32
-		assert.Equal(t, v.Original, expected[i])
32
+		assert.Equal(t, expected[i], v.Original)
33 33
 	}
34 34
 }
... ...
@@ -10,8 +10,8 @@ import (
10 10
 	"github.com/docker/docker/api/types/container"
11 11
 	"github.com/docker/docker/api/types/strslice"
12 12
 	"github.com/docker/docker/builder"
13
-	"github.com/docker/docker/pkg/testutil/assert"
14 13
 	"github.com/docker/go-connections/nat"
14
+	"github.com/stretchr/testify/assert"
15 15
 )
16 16
 
17 17
 type commandWithFunction struct {
... ...
@@ -137,13 +137,13 @@ func TestEnv2Variables(t *testing.T) {
137 137
 
138 138
 	args := []string{"var1", "val1", "var2", "val2"}
139 139
 	err := env(b, args, nil, "")
140
-	assert.NilError(t, err)
140
+	assert.NoError(t, err)
141 141
 
142 142
 	expected := []string{
143 143
 		fmt.Sprintf("%s=%s", args[0], args[1]),
144 144
 		fmt.Sprintf("%s=%s", args[2], args[3]),
145 145
 	}
146
-	assert.DeepEqual(t, b.runConfig.Env, expected)
146
+	assert.Equal(t, expected, b.runConfig.Env)
147 147
 }
148 148
 
149 149
 func TestEnvValueWithExistingRunConfigEnv(t *testing.T) {
... ...
@@ -153,13 +153,13 @@ func TestEnvValueWithExistingRunConfigEnv(t *testing.T) {
153 153
 
154 154
 	args := []string{"var1", "val1"}
155 155
 	err := env(b, args, nil, "")
156
-	assert.NilError(t, err)
156
+	assert.NoError(t, err)
157 157
 
158 158
 	expected := []string{
159 159
 		fmt.Sprintf("%s=%s", args[0], args[1]),
160 160
 		"var2=fromenv",
161 161
 	}
162
-	assert.DeepEqual(t, b.runConfig.Env, expected)
162
+	assert.Equal(t, expected, b.runConfig.Env)
163 163
 }
164 164
 
165 165
 func TestMaintainer(t *testing.T) {
... ...
@@ -215,40 +215,40 @@ func TestFromScratch(t *testing.T) {
215 215
 	err := from(b, []string{"scratch"}, nil, "")
216 216
 
217 217
 	if runtime.GOOS == "windows" {
218
-		assert.Error(t, err, "Windows does not support FROM scratch")
218
+		assert.EqualError(t, err, "Windows does not support FROM scratch")
219 219
 		return
220 220
 	}
221 221
 
222
-	assert.NilError(t, err)
223
-	assert.Equal(t, b.image, "")
224
-	assert.Equal(t, b.noBaseImage, true)
222
+	assert.NoError(t, err)
223
+	assert.Equal(t, "", b.image)
224
+	assert.Equal(t, true, b.noBaseImage)
225 225
 }
226 226
 
227 227
 func TestFromWithArg(t *testing.T) {
228 228
 	tag, expected := ":sometag", "expectedthisid"
229 229
 
230 230
 	getImage := func(name string) (builder.Image, error) {
231
-		assert.Equal(t, name, "alpine"+tag)
231
+		assert.Equal(t, "alpine"+tag, name)
232 232
 		return &mockImage{id: "expectedthisid"}, nil
233 233
 	}
234 234
 	b := newBuilderWithMockBackend()
235 235
 	b.docker.(*MockBackend).getImageOnBuildFunc = getImage
236 236
 
237
-	assert.NilError(t, arg(b, []string{"THETAG=" + tag}, nil, ""))
237
+	assert.NoError(t, arg(b, []string{"THETAG=" + tag}, nil, ""))
238 238
 	err := from(b, []string{"alpine${THETAG}"}, nil, "")
239 239
 
240
-	assert.NilError(t, err)
241
-	assert.Equal(t, b.image, expected)
242
-	assert.Equal(t, b.from.ImageID(), expected)
243
-	assert.Equal(t, len(b.buildArgs.GetAllAllowed()), 0)
244
-	assert.Equal(t, len(b.buildArgs.GetAllMeta()), 1)
240
+	assert.NoError(t, err)
241
+	assert.Equal(t, expected, b.image)
242
+	assert.Equal(t, expected, b.from.ImageID())
243
+	assert.Len(t, b.buildArgs.GetAllAllowed(), 0)
244
+	assert.Len(t, b.buildArgs.GetAllMeta(), 1)
245 245
 }
246 246
 
247 247
 func TestFromWithUndefinedArg(t *testing.T) {
248 248
 	tag, expected := "sometag", "expectedthisid"
249 249
 
250 250
 	getImage := func(name string) (builder.Image, error) {
251
-		assert.Equal(t, name, "alpine")
251
+		assert.Equal(t, "alpine", name)
252 252
 		return &mockImage{id: "expectedthisid"}, nil
253 253
 	}
254 254
 	b := newBuilderWithMockBackend()
... ...
@@ -256,8 +256,8 @@ func TestFromWithUndefinedArg(t *testing.T) {
256 256
 	b.options.BuildArgs = map[string]*string{"THETAG": &tag}
257 257
 
258 258
 	err := from(b, []string{"alpine${THETAG}"}, nil, "")
259
-	assert.NilError(t, err)
260
-	assert.Equal(t, b.image, expected)
259
+	assert.NoError(t, err)
260
+	assert.Equal(t, expected, b.image)
261 261
 }
262 262
 
263 263
 func TestOnbuildIllegalTriggers(t *testing.T) {
... ...
@@ -508,11 +508,11 @@ func TestArg(t *testing.T) {
508 508
 	argDef := fmt.Sprintf("%s=%s", argName, argVal)
509 509
 
510 510
 	err := arg(b, []string{argDef}, nil, "")
511
-	assert.NilError(t, err)
511
+	assert.NoError(t, err)
512 512
 
513 513
 	expected := map[string]string{argName: argVal}
514 514
 	allowed := b.buildArgs.GetAllAllowed()
515
-	assert.DeepEqual(t, allowed, expected)
515
+	assert.Equal(t, expected, allowed)
516 516
 }
517 517
 
518 518
 func TestShell(t *testing.T) {
... ...
@@ -7,7 +7,8 @@ import (
7 7
 	"github.com/docker/docker/api/types"
8 8
 	"github.com/docker/docker/builder"
9 9
 	"github.com/docker/docker/pkg/archive"
10
-	"github.com/docker/docker/pkg/testutil/assert"
10
+	"github.com/stretchr/testify/assert"
11
+	"github.com/stretchr/testify/require"
11 12
 )
12 13
 
13 14
 func TestEmptyDockerfile(t *testing.T) {
... ...
@@ -38,7 +39,7 @@ func TestDockerfileOutsideTheBuildContext(t *testing.T) {
38 38
 	contextDir, cleanup := createTestTempDir(t, "", "builder-dockerfile-test")
39 39
 	defer cleanup()
40 40
 
41
-	expectedError := "Forbidden path outside the build context"
41
+	expectedError := "Forbidden path outside the build context: ../../Dockerfile ()"
42 42
 
43 43
 	readAndCheckDockerfile(t, "DockerfileOutsideTheBuildContext", contextDir, "../../Dockerfile", expectedError)
44 44
 }
... ...
@@ -54,7 +55,7 @@ func TestNonExistingDockerfile(t *testing.T) {
54 54
 
55 55
 func readAndCheckDockerfile(t *testing.T, testName, contextDir, dockerfilePath, expectedError string) {
56 56
 	tarStream, err := archive.Tar(contextDir, archive.Uncompressed)
57
-	assert.NilError(t, err)
57
+	require.NoError(t, err)
58 58
 
59 59
 	defer func() {
60 60
 		if err = tarStream.Close(); err != nil {
... ...
@@ -63,7 +64,7 @@ func readAndCheckDockerfile(t *testing.T, testName, contextDir, dockerfilePath,
63 63
 	}()
64 64
 
65 65
 	context, err := builder.MakeTarSumContext(tarStream)
66
-	assert.NilError(t, err)
66
+	require.NoError(t, err)
67 67
 
68 68
 	defer func() {
69 69
 		if err = context.Close(); err != nil {
... ...
@@ -78,5 +79,5 @@ func readAndCheckDockerfile(t *testing.T, testName, contextDir, dockerfilePath,
78 78
 	b := &Builder{options: options, context: context}
79 79
 
80 80
 	_, err = b.readAndParseDockerfile()
81
-	assert.Error(t, err, expectedError)
81
+	assert.EqualError(t, err, expectedError)
82 82
 }
... ...
@@ -1,26 +1,27 @@
1 1
 package parser
2 2
 
3 3
 import (
4
-	"github.com/docker/docker/pkg/testutil/assert"
5 4
 	"testing"
5
+
6
+	"github.com/stretchr/testify/assert"
6 7
 )
7 8
 
8 9
 func TestParseNameValOldFormat(t *testing.T) {
9 10
 	directive := Directive{}
10 11
 	node, err := parseNameVal("foo bar", "LABEL", &directive)
11
-	assert.NilError(t, err)
12
+	assert.NoError(t, err)
12 13
 
13 14
 	expected := &Node{
14 15
 		Value: "foo",
15 16
 		Next:  &Node{Value: "bar"},
16 17
 	}
17
-	assert.DeepEqual(t, node, expected)
18
+	assert.Equal(t, expected, node)
18 19
 }
19 20
 
20 21
 func TestParseNameValNewFormat(t *testing.T) {
21 22
 	directive := Directive{}
22 23
 	node, err := parseNameVal("foo=bar thing=star", "LABEL", &directive)
23
-	assert.NilError(t, err)
24
+	assert.NoError(t, err)
24 25
 
25 26
 	expected := &Node{
26 27
 		Value: "foo",
... ...
@@ -34,7 +35,7 @@ func TestParseNameValNewFormat(t *testing.T) {
34 34
 			},
35 35
 		},
36 36
 	}
37
-	assert.DeepEqual(t, node, expected)
37
+	assert.Equal(t, expected, node)
38 38
 }
39 39
 
40 40
 func TestNodeFromLabels(t *testing.T) {
... ...
@@ -60,6 +61,6 @@ func TestNodeFromLabels(t *testing.T) {
60 60
 	}
61 61
 
62 62
 	node := NodeFromLabels(labels)
63
-	assert.DeepEqual(t, node, expected)
63
+	assert.Equal(t, expected, node)
64 64
 
65 65
 }
... ...
@@ -9,7 +9,8 @@ import (
9 9
 	"runtime"
10 10
 	"testing"
11 11
 
12
-	"github.com/docker/docker/pkg/testutil/assert"
12
+	"github.com/stretchr/testify/assert"
13
+	"github.com/stretchr/testify/require"
13 14
 )
14 15
 
15 16
 const testDir = "testfiles"
... ...
@@ -18,11 +19,11 @@ const testFileLineInfo = "testfile-line/Dockerfile"
18 18
 
19 19
 func getDirs(t *testing.T, dir string) []string {
20 20
 	f, err := os.Open(dir)
21
-	assert.NilError(t, err)
21
+	require.NoError(t, err)
22 22
 	defer f.Close()
23 23
 
24 24
 	dirs, err := f.Readdirnames(0)
25
-	assert.NilError(t, err)
25
+	require.NoError(t, err)
26 26
 	return dirs
27 27
 }
28 28
 
... ...
@@ -31,11 +32,11 @@ func TestTestNegative(t *testing.T) {
31 31
 		dockerfile := filepath.Join(negativeTestDir, dir, "Dockerfile")
32 32
 
33 33
 		df, err := os.Open(dockerfile)
34
-		assert.NilError(t, err)
34
+		require.NoError(t, err)
35 35
 		defer df.Close()
36 36
 
37 37
 		_, err = Parse(df)
38
-		assert.Error(t, err, "")
38
+		assert.Error(t, err)
39 39
 	}
40 40
 }
41 41
 
... ...
@@ -45,21 +46,21 @@ func TestTestData(t *testing.T) {
45 45
 		resultfile := filepath.Join(testDir, dir, "result")
46 46
 
47 47
 		df, err := os.Open(dockerfile)
48
-		assert.NilError(t, err)
48
+		require.NoError(t, err)
49 49
 		defer df.Close()
50 50
 
51 51
 		result, err := Parse(df)
52
-		assert.NilError(t, err)
52
+		require.NoError(t, err)
53 53
 
54 54
 		content, err := ioutil.ReadFile(resultfile)
55
-		assert.NilError(t, err)
55
+		require.NoError(t, err)
56 56
 
57 57
 		if runtime.GOOS == "windows" {
58 58
 			// CRLF --> CR to match Unix behavior
59 59
 			content = bytes.Replace(content, []byte{'\x0d', '\x0a'}, []byte{'\x0a'}, -1)
60 60
 		}
61 61
 
62
-		assert.Equal(t, result.AST.Dump()+"\n", string(content), "In "+dockerfile)
62
+		assert.Contains(t, result.AST.Dump()+"\n", string(content), "In "+dockerfile)
63 63
 	}
64 64
 }
65 65
 
... ...
@@ -101,24 +102,24 @@ func TestParseWords(t *testing.T) {
101 101
 
102 102
 	for _, test := range tests {
103 103
 		words := parseWords(test["input"][0], NewDefaultDirective())
104
-		assert.DeepEqual(t, words, test["expect"])
104
+		assert.Equal(t, test["expect"], words)
105 105
 	}
106 106
 }
107 107
 
108 108
 func TestLineInformation(t *testing.T) {
109 109
 	df, err := os.Open(testFileLineInfo)
110
-	assert.NilError(t, err)
110
+	require.NoError(t, err)
111 111
 	defer df.Close()
112 112
 
113 113
 	result, err := Parse(df)
114
-	assert.NilError(t, err)
114
+	require.NoError(t, err)
115 115
 
116 116
 	ast := result.AST
117 117
 	if ast.StartLine != 5 || ast.endLine != 31 {
118 118
 		fmt.Fprintf(os.Stderr, "Wrong root line information: expected(%d-%d), actual(%d-%d)\n", 5, 31, ast.StartLine, ast.endLine)
119 119
 		t.Fatal("Root line information doesn't match result.")
120 120
 	}
121
-	assert.Equal(t, len(ast.Children), 3)
121
+	assert.Len(t, ast.Children, 3)
122 122
 	expected := [][]int{
123 123
 		{5, 5},
124 124
 		{11, 12},
... ...
@@ -7,7 +7,7 @@ import (
7 7
 	"strings"
8 8
 	"testing"
9 9
 
10
-	"github.com/docker/docker/pkg/testutil/assert"
10
+	"github.com/stretchr/testify/assert"
11 11
 )
12 12
 
13 13
 func TestShellParser4EnvVars(t *testing.T) {
... ...
@@ -15,7 +15,7 @@ func TestShellParser4EnvVars(t *testing.T) {
15 15
 	lineCount := 0
16 16
 
17 17
 	file, err := os.Open(fn)
18
-	assert.NilError(t, err)
18
+	assert.NoError(t, err)
19 19
 	defer file.Close()
20 20
 
21 21
 	scanner := bufio.NewScanner(file)
... ...
@@ -36,7 +36,7 @@ func TestShellParser4EnvVars(t *testing.T) {
36 36
 		}
37 37
 
38 38
 		words := strings.Split(line, "|")
39
-		assert.Equal(t, len(words), 3)
39
+		assert.Len(t, words, 3)
40 40
 
41 41
 		platform := strings.TrimSpace(words[0])
42 42
 		source := strings.TrimSpace(words[1])
... ...
@@ -51,9 +51,9 @@ func TestShellParser4EnvVars(t *testing.T) {
51 51
 			((platform == "U" || platform == "A") && runtime.GOOS != "windows") {
52 52
 			newWord, err := ProcessWord(source, envs, '\\')
53 53
 			if expected == "error" {
54
-				assert.Error(t, err, "")
54
+				assert.Error(t, err)
55 55
 			} else {
56
-				assert.NilError(t, err)
56
+				assert.NoError(t, err)
57 57
 				assert.Equal(t, newWord, expected)
58 58
 			}
59 59
 		}
... ...
@@ -5,7 +5,7 @@ import (
5 5
 	"strings"
6 6
 	"testing"
7 7
 
8
-	"github.com/docker/docker/pkg/testutil/assert"
8
+	"github.com/stretchr/testify/assert"
9 9
 )
10 10
 
11 11
 func TestLoadFileV01Success(t *testing.T) {
... ...
@@ -25,9 +25,9 @@ func TestLoadFileV01Success(t *testing.T) {
25 25
 	}`)
26 26
 
27 27
 	bundle, err := LoadFile(reader)
28
-	assert.NilError(t, err)
29
-	assert.Equal(t, bundle.Version, "0.1")
30
-	assert.Equal(t, len(bundle.Services), 2)
28
+	assert.NoError(t, err)
29
+	assert.Equal(t, "0.1", bundle.Version)
30
+	assert.Len(t, bundle.Services, 2)
31 31
 }
32 32
 
33 33
 func TestLoadFileSyntaxError(t *testing.T) {
... ...
@@ -37,7 +37,7 @@ func TestLoadFileSyntaxError(t *testing.T) {
37 37
 	}`)
38 38
 
39 39
 	_, err := LoadFile(reader)
40
-	assert.Error(t, err, "syntax error at byte 37: invalid character 'u'")
40
+	assert.EqualError(t, err, "JSON syntax error at byte 37: invalid character 'u' looking for beginning of value")
41 41
 }
42 42
 
43 43
 func TestLoadFileTypeError(t *testing.T) {
... ...
@@ -52,7 +52,7 @@ func TestLoadFileTypeError(t *testing.T) {
52 52
 	}`)
53 53
 
54 54
 	_, err := LoadFile(reader)
55
-	assert.Error(t, err, "Unexpected type at byte 94. Expected []string but received string")
55
+	assert.EqualError(t, err, "Unexpected type at byte 94. Expected []string but received string.")
56 56
 }
57 57
 
58 58
 func TestPrint(t *testing.T) {
... ...
@@ -66,7 +66,7 @@ func TestPrint(t *testing.T) {
66 66
 			},
67 67
 		},
68 68
 	}
69
-	assert.NilError(t, Print(&buffer, bundle))
69
+	assert.NoError(t, Print(&buffer, bundle))
70 70
 	output := buffer.String()
71 71
 	assert.Contains(t, output, "\"Image\": \"image\"")
72 72
 	assert.Contains(t, output,
... ...
@@ -13,11 +13,12 @@ import (
13 13
 
14 14
 	"github.com/docker/docker/api/types/container"
15 15
 	networktypes "github.com/docker/docker/api/types/network"
16
-	"github.com/docker/docker/pkg/testutil/assert"
16
+	"github.com/docker/docker/pkg/testutil"
17 17
 	"github.com/docker/docker/runconfig"
18 18
 	"github.com/docker/go-connections/nat"
19 19
 	"github.com/pkg/errors"
20 20
 	"github.com/spf13/pflag"
21
+	"github.com/stretchr/testify/assert"
21 22
 )
22 23
 
23 24
 func TestValidateAttach(t *testing.T) {
... ...
@@ -243,23 +244,23 @@ func TestParseWithMacAddress(t *testing.T) {
243 243
 func TestParseWithMemory(t *testing.T) {
244 244
 	invalidMemory := "--memory=invalid"
245 245
 	_, _, _, err := parseRun([]string{invalidMemory, "img", "cmd"})
246
-	assert.Error(t, err, invalidMemory)
246
+	testutil.ErrorContains(t, err, invalidMemory)
247 247
 
248 248
 	_, hostconfig := mustParse(t, "--memory=1G")
249
-	assert.Equal(t, hostconfig.Memory, int64(1073741824))
249
+	assert.Equal(t, int64(1073741824), hostconfig.Memory)
250 250
 }
251 251
 
252 252
 func TestParseWithMemorySwap(t *testing.T) {
253 253
 	invalidMemory := "--memory-swap=invalid"
254 254
 
255 255
 	_, _, _, err := parseRun([]string{invalidMemory, "img", "cmd"})
256
-	assert.Error(t, err, invalidMemory)
256
+	testutil.ErrorContains(t, err, invalidMemory)
257 257
 
258 258
 	_, hostconfig := mustParse(t, "--memory-swap=1G")
259
-	assert.Equal(t, hostconfig.MemorySwap, int64(1073741824))
259
+	assert.Equal(t, int64(1073741824), hostconfig.MemorySwap)
260 260
 
261 261
 	_, hostconfig = mustParse(t, "--memory-swap=-1")
262
-	assert.Equal(t, hostconfig.MemorySwap, int64(-1))
262
+	assert.Equal(t, int64(-1), hostconfig.MemorySwap)
263 263
 }
264 264
 
265 265
 func TestParseHostname(t *testing.T) {
... ...
@@ -4,13 +4,13 @@ import (
4 4
 	"testing"
5 5
 
6 6
 	"github.com/docker/docker/opts"
7
-	"github.com/docker/docker/pkg/testutil/assert"
7
+	"github.com/stretchr/testify/assert"
8 8
 )
9 9
 
10 10
 func TestBuildContainerListOptions(t *testing.T) {
11 11
 	filters := opts.NewFilterOpt()
12
-	assert.NilError(t, filters.Set("foo=bar"))
13
-	assert.NilError(t, filters.Set("baz=foo"))
12
+	assert.NoError(t, filters.Set("foo=bar"))
13
+	assert.NoError(t, filters.Set("baz=foo"))
14 14
 
15 15
 	contexts := []struct {
16 16
 		psOpts          *psOptions
... ...
@@ -101,12 +101,12 @@ func TestBuildContainerListOptions(t *testing.T) {
101 101
 
102 102
 	for _, c := range contexts {
103 103
 		options, err := buildContainerListOptions(c.psOpts)
104
-		assert.NilError(t, err)
104
+		assert.NoError(t, err)
105 105
 
106 106
 		assert.Equal(t, c.expectedAll, options.All)
107 107
 		assert.Equal(t, c.expectedSize, options.Size)
108 108
 		assert.Equal(t, c.expectedLimit, options.Limit)
109
-		assert.Equal(t, options.Filters.Len(), len(c.expectedFilters))
109
+		assert.Equal(t, len(c.expectedFilters), options.Filters.Len())
110 110
 
111 111
 		for k, v := range c.expectedFilters {
112 112
 			f := options.Filters
... ...
@@ -10,7 +10,7 @@ import (
10 10
 
11 11
 	"github.com/docker/docker/api/types"
12 12
 	"github.com/docker/docker/pkg/stringid"
13
-	"github.com/docker/docker/pkg/testutil/assert"
13
+	"github.com/stretchr/testify/assert"
14 14
 )
15 15
 
16 16
 func TestContainerPsContext(t *testing.T) {
... ...
@@ -245,9 +245,9 @@ conta               "ubuntu" 24 hours ago//.FOOBAR_BAR
245 245
 		testcase.context.Output = out
246 246
 		err := ContainerWrite(testcase.context, containers)
247 247
 		if err != nil {
248
-			assert.Error(t, err, testcase.expected)
248
+			assert.EqualError(t, err, testcase.expected)
249 249
 		} else {
250
-			assert.Equal(t, out.String(), testcase.expected)
250
+			assert.Equal(t, testcase.expected, out.String())
251 251
 		}
252 252
 	}
253 253
 }
... ...
@@ -334,7 +334,7 @@ func TestContainerContextWriteJSON(t *testing.T) {
334 334
 		if err := json.Unmarshal([]byte(line), &m); err != nil {
335 335
 			t.Fatal(err)
336 336
 		}
337
-		assert.DeepEqual(t, m, expectedJSONs[i])
337
+		assert.Equal(t, expectedJSONs[i], m)
338 338
 	}
339 339
 }
340 340
 
... ...
@@ -354,7 +354,7 @@ func TestContainerContextWriteJSONField(t *testing.T) {
354 354
 		if err := json.Unmarshal([]byte(line), &s); err != nil {
355 355
 			t.Fatal(err)
356 356
 		}
357
-		assert.Equal(t, s, containers[i].ID)
357
+		assert.Equal(t, containers[i].ID, s)
358 358
 	}
359 359
 }
360 360
 
... ...
@@ -6,7 +6,7 @@ import (
6 6
 
7 7
 	"github.com/docker/docker/api/types/container"
8 8
 	"github.com/docker/docker/pkg/archive"
9
-	"github.com/docker/docker/pkg/testutil/assert"
9
+	"github.com/stretchr/testify/assert"
10 10
 )
11 11
 
12 12
 func TestDiffContextFormatWrite(t *testing.T) {
... ...
@@ -51,9 +51,9 @@ D: /usr/app/old_app.js
51 51
 		testcase.context.Output = out
52 52
 		err := DiffWrite(testcase.context, diffs)
53 53
 		if err != nil {
54
-			assert.Error(t, err, testcase.expected)
54
+			assert.EqualError(t, err, testcase.expected)
55 55
 		} else {
56
-			assert.Equal(t, out.String(), testcase.expected)
56
+			assert.Equal(t, testcase.expected, out.String())
57 57
 		}
58 58
 	}
59 59
 }
... ...
@@ -4,7 +4,7 @@ import (
4 4
 	"bytes"
5 5
 	"testing"
6 6
 
7
-	"github.com/docker/docker/pkg/testutil/assert"
7
+	"github.com/stretchr/testify/assert"
8 8
 )
9 9
 
10 10
 func TestDiskUsageContextFormatWrite(t *testing.T) {
... ...
@@ -117,9 +117,9 @@ reclaimable: 0B
117 117
 		out := bytes.NewBufferString("")
118 118
 		testcase.context.Output = out
119 119
 		if err := testcase.context.Write(); err != nil {
120
-			assert.Equal(t, err.Error(), testcase.expected)
120
+			assert.Equal(t, testcase.expected, err.Error())
121 121
 		} else {
122
-			assert.Equal(t, out.String(), testcase.expected)
122
+			assert.Equal(t, testcase.expected, out.String())
123 123
 		}
124 124
 	}
125 125
 }
... ...
@@ -9,7 +9,7 @@ import (
9 9
 
10 10
 	"github.com/docker/docker/api/types"
11 11
 	"github.com/docker/docker/pkg/stringid"
12
-	"github.com/docker/docker/pkg/testutil/assert"
12
+	"github.com/stretchr/testify/assert"
13 13
 )
14 14
 
15 15
 func TestImageContext(t *testing.T) {
... ...
@@ -265,9 +265,9 @@ image_id: imageID3
265 265
 		testcase.context.Output = out
266 266
 		err := ImageWrite(testcase.context, images)
267 267
 		if err != nil {
268
-			assert.Error(t, err, testcase.expected)
268
+			assert.EqualError(t, err, testcase.expected)
269 269
 		} else {
270
-			assert.Equal(t, out.String(), testcase.expected)
270
+			assert.Equal(t, testcase.expected, out.String())
271 271
 		}
272 272
 	}
273 273
 }
... ...
@@ -320,7 +320,7 @@ func TestImageContextWriteWithNoImage(t *testing.T) {
320 320
 
321 321
 	for _, context := range contexts {
322 322
 		ImageWrite(context.context, images)
323
-		assert.Equal(t, out.String(), context.expected)
323
+		assert.Equal(t, context.expected, out.String())
324 324
 		// Clean buffer
325 325
 		out.Reset()
326 326
 	}
... ...
@@ -9,7 +9,7 @@ import (
9 9
 
10 10
 	"github.com/docker/docker/api/types"
11 11
 	"github.com/docker/docker/pkg/stringid"
12
-	"github.com/docker/docker/pkg/testutil/assert"
12
+	"github.com/stretchr/testify/assert"
13 13
 )
14 14
 
15 15
 func TestNetworkContext(t *testing.T) {
... ...
@@ -160,9 +160,9 @@ foobar_bar 2017-01-01 00:00:00 +0000 UTC
160 160
 		testcase.context.Output = out
161 161
 		err := NetworkWrite(testcase.context, networks)
162 162
 		if err != nil {
163
-			assert.Error(t, err, testcase.expected)
163
+			assert.EqualError(t, err, testcase.expected)
164 164
 		} else {
165
-			assert.Equal(t, out.String(), testcase.expected)
165
+			assert.Equal(t, testcase.expected, out.String())
166 166
 		}
167 167
 	}
168 168
 }
... ...
@@ -188,7 +188,7 @@ func TestNetworkContextWriteJSON(t *testing.T) {
188 188
 		if err := json.Unmarshal([]byte(line), &m); err != nil {
189 189
 			t.Fatal(err)
190 190
 		}
191
-		assert.DeepEqual(t, m, expectedJSONs[i])
191
+		assert.Equal(t, expectedJSONs[i], m)
192 192
 	}
193 193
 }
194 194
 
... ...
@@ -208,6 +208,6 @@ func TestNetworkContextWriteJSONField(t *testing.T) {
208 208
 		if err := json.Unmarshal([]byte(line), &s); err != nil {
209 209
 			t.Fatal(err)
210 210
 		}
211
-		assert.Equal(t, s, networks[i].ID)
211
+		assert.Equal(t, networks[i].ID, s)
212 212
 	}
213 213
 }
... ...
@@ -9,7 +9,7 @@ import (
9 9
 	"github.com/docker/docker/api/types"
10 10
 	"github.com/docker/docker/api/types/swarm"
11 11
 	"github.com/docker/docker/pkg/stringid"
12
-	"github.com/docker/docker/pkg/testutil/assert"
12
+	"github.com/stretchr/testify/assert"
13 13
 )
14 14
 
15 15
 func TestNodeContext(t *testing.T) {
... ...
@@ -135,9 +135,9 @@ foobar_bar
135 135
 		testcase.context.Output = out
136 136
 		err := NodeWrite(testcase.context, nodes, types.Info{})
137 137
 		if err != nil {
138
-			assert.Error(t, err, testcase.expected)
138
+			assert.EqualError(t, err, testcase.expected)
139 139
 		} else {
140
-			assert.Equal(t, out.String(), testcase.expected)
140
+			assert.Equal(t, testcase.expected, out.String())
141 141
 		}
142 142
 	}
143 143
 }
... ...
@@ -163,7 +163,7 @@ func TestNodeContextWriteJSON(t *testing.T) {
163 163
 		if err := json.Unmarshal([]byte(line), &m); err != nil {
164 164
 			t.Fatal(err)
165 165
 		}
166
-		assert.DeepEqual(t, m, expectedJSONs[i])
166
+		assert.Equal(t, expectedJSONs[i], m)
167 167
 	}
168 168
 }
169 169
 
... ...
@@ -183,6 +183,6 @@ func TestNodeContextWriteJSONField(t *testing.T) {
183 183
 		if err := json.Unmarshal([]byte(line), &s); err != nil {
184 184
 			t.Fatal(err)
185 185
 		}
186
-		assert.Equal(t, s, nodes[i].ID)
186
+		assert.Equal(t, nodes[i].ID, s)
187 187
 	}
188 188
 }
... ...
@@ -8,7 +8,7 @@ import (
8 8
 
9 9
 	"github.com/docker/docker/api/types"
10 10
 	"github.com/docker/docker/pkg/stringid"
11
-	"github.com/docker/docker/pkg/testutil/assert"
11
+	"github.com/stretchr/testify/assert"
12 12
 )
13 13
 
14 14
 func TestPluginContext(t *testing.T) {
... ...
@@ -131,9 +131,9 @@ foobar_bar
131 131
 		testcase.context.Output = out
132 132
 		err := PluginWrite(testcase.context, plugins)
133 133
 		if err != nil {
134
-			assert.Error(t, err, testcase.expected)
134
+			assert.EqualError(t, err, testcase.expected)
135 135
 		} else {
136
-			assert.Equal(t, out.String(), testcase.expected)
136
+			assert.Equal(t, testcase.expected, out.String())
137 137
 		}
138 138
 	}
139 139
 }
... ...
@@ -158,7 +158,7 @@ func TestPluginContextWriteJSON(t *testing.T) {
158 158
 		if err := json.Unmarshal([]byte(line), &m); err != nil {
159 159
 			t.Fatal(err)
160 160
 		}
161
-		assert.DeepEqual(t, m, expectedJSONs[i])
161
+		assert.Equal(t, expectedJSONs[i], m)
162 162
 	}
163 163
 }
164 164
 
... ...
@@ -177,6 +177,6 @@ func TestPluginContextWriteJSONField(t *testing.T) {
177 177
 		if err := json.Unmarshal([]byte(line), &s); err != nil {
178 178
 			t.Fatal(err)
179 179
 		}
180
-		assert.Equal(t, s, plugins[i].ID)
180
+		assert.Equal(t, plugins[i].ID, s)
181 181
 	}
182 182
 }
... ...
@@ -6,7 +6,7 @@ import (
6 6
 	"time"
7 7
 
8 8
 	"github.com/docker/docker/api/types/swarm"
9
-	"github.com/docker/docker/pkg/testutil/assert"
9
+	"github.com/stretchr/testify/assert"
10 10
 )
11 11
 
12 12
 func TestSecretContextFormatWrite(t *testing.T) {
... ...
@@ -55,9 +55,9 @@ id_rsa
55 55
 		out := bytes.NewBufferString("")
56 56
 		testcase.context.Output = out
57 57
 		if err := SecretWrite(testcase.context, secrets); err != nil {
58
-			assert.Error(t, err, testcase.expected)
58
+			assert.EqualError(t, err, testcase.expected)
59 59
 		} else {
60
-			assert.Equal(t, out.String(), testcase.expected)
60
+			assert.Equal(t, testcase.expected, out.String())
61 61
 		}
62 62
 	}
63 63
 }
... ...
@@ -7,7 +7,7 @@ import (
7 7
 	"testing"
8 8
 
9 9
 	"github.com/docker/docker/api/types/swarm"
10
-	"github.com/docker/docker/pkg/testutil/assert"
10
+	"github.com/stretchr/testify/assert"
11 11
 )
12 12
 
13 13
 func TestServiceContextWrite(t *testing.T) {
... ...
@@ -137,9 +137,9 @@ bar
137 137
 		testcase.context.Output = out
138 138
 		err := ServiceListWrite(testcase.context, services, info)
139 139
 		if err != nil {
140
-			assert.Error(t, err, testcase.expected)
140
+			assert.EqualError(t, err, testcase.expected)
141 141
 		} else {
142
-			assert.Equal(t, out.String(), testcase.expected)
142
+			assert.Equal(t, testcase.expected, out.String())
143 143
 		}
144 144
 	}
145 145
 }
... ...
@@ -205,7 +205,7 @@ func TestServiceContextWriteJSON(t *testing.T) {
205 205
 		if err := json.Unmarshal([]byte(line), &m); err != nil {
206 206
 			t.Fatal(err)
207 207
 		}
208
-		assert.DeepEqual(t, m, expectedJSONs[i])
208
+		assert.Equal(t, expectedJSONs[i], m)
209 209
 	}
210 210
 }
211 211
 func TestServiceContextWriteJSONField(t *testing.T) {
... ...
@@ -234,6 +234,6 @@ func TestServiceContextWriteJSONField(t *testing.T) {
234 234
 		if err := json.Unmarshal([]byte(line), &s); err != nil {
235 235
 			t.Fatal(err)
236 236
 		}
237
-		assert.Equal(t, s, services[i].Spec.Name)
237
+		assert.Equal(t, services[i].Spec.Name, s)
238 238
 	}
239 239
 }
... ...
@@ -5,7 +5,7 @@ import (
5 5
 	"testing"
6 6
 
7 7
 	"github.com/docker/docker/pkg/stringid"
8
-	"github.com/docker/docker/pkg/testutil/assert"
8
+	"github.com/stretchr/testify/assert"
9 9
 )
10 10
 
11 11
 func TestContainerStatsContext(t *testing.T) {
... ...
@@ -116,9 +116,9 @@ container2  --
116 116
 		te.context.Output = &out
117 117
 		err := ContainerStatsWrite(te.context, stats, "linux")
118 118
 		if err != nil {
119
-			assert.Error(t, err, te.expected)
119
+			assert.EqualError(t, err, te.expected)
120 120
 		} else {
121
-			assert.Equal(t, out.String(), te.expected)
121
+			assert.Equal(t, te.expected, out.String())
122 122
 		}
123 123
 	}
124 124
 }
... ...
@@ -182,9 +182,9 @@ container2  --  --
182 182
 		te.context.Output = &out
183 183
 		err := ContainerStatsWrite(te.context, stats, "windows")
184 184
 		if err != nil {
185
-			assert.Error(t, err, te.expected)
185
+			assert.EqualError(t, err, te.expected)
186 186
 		} else {
187
-			assert.Equal(t, out.String(), te.expected)
187
+			assert.Equal(t, te.expected, out.String())
188 188
 		}
189 189
 	}
190 190
 }
... ...
@@ -259,7 +259,7 @@ func TestContainerStatsContextWriteWithNoStatsWindows(t *testing.T) {
259 259
 
260 260
 	for _, context := range contexts {
261 261
 		ContainerStatsWrite(context.context, []StatsEntry{}, "windows")
262
-		assert.Equal(t, out.String(), context.expected)
262
+		assert.Equal(t, context.expected, out.String())
263 263
 		// Clean buffer
264 264
 		out.Reset()
265 265
 	}
... ...
@@ -7,7 +7,7 @@ import (
7 7
 	"testing"
8 8
 
9 9
 	"github.com/docker/docker/api/types/swarm"
10
-	"github.com/docker/docker/pkg/testutil/assert"
10
+	"github.com/stretchr/testify/assert"
11 11
 )
12 12
 
13 13
 func TestTaskContextWrite(t *testing.T) {
... ...
@@ -76,9 +76,9 @@ foobar_bar foo2
76 76
 		testcase.context.Output = out
77 77
 		err := TaskWrite(testcase.context, tasks, names, nodes)
78 78
 		if err != nil {
79
-			assert.Error(t, err, testcase.expected)
79
+			assert.EqualError(t, err, testcase.expected)
80 80
 		} else {
81
-			assert.Equal(t, out.String(), testcase.expected)
81
+			assert.Equal(t, testcase.expected, out.String())
82 82
 		}
83 83
 	}
84 84
 }
... ...
@@ -102,6 +102,6 @@ func TestTaskContextWriteJSONField(t *testing.T) {
102 102
 		if err := json.Unmarshal([]byte(line), &s); err != nil {
103 103
 			t.Fatal(err)
104 104
 		}
105
-		assert.Equal(t, s, tasks[i].ID)
105
+		assert.Equal(t, tasks[i].ID, s)
106 106
 	}
107 107
 }
... ...
@@ -8,7 +8,7 @@ import (
8 8
 
9 9
 	"github.com/docker/docker/api/types"
10 10
 	"github.com/docker/docker/pkg/stringid"
11
-	"github.com/docker/docker/pkg/testutil/assert"
11
+	"github.com/stretchr/testify/assert"
12 12
 )
13 13
 
14 14
 func TestVolumeContext(t *testing.T) {
... ...
@@ -131,9 +131,9 @@ foobar_bar
131 131
 		testcase.context.Output = out
132 132
 		err := VolumeWrite(testcase.context, volumes)
133 133
 		if err != nil {
134
-			assert.Error(t, err, testcase.expected)
134
+			assert.EqualError(t, err, testcase.expected)
135 135
 		} else {
136
-			assert.Equal(t, out.String(), testcase.expected)
136
+			assert.Equal(t, testcase.expected, out.String())
137 137
 		}
138 138
 	}
139 139
 }
... ...
@@ -158,7 +158,7 @@ func TestVolumeContextWriteJSON(t *testing.T) {
158 158
 		if err := json.Unmarshal([]byte(line), &m); err != nil {
159 159
 			t.Fatal(err)
160 160
 		}
161
-		assert.DeepEqual(t, m, expectedJSONs[i])
161
+		assert.Equal(t, expectedJSONs[i], m)
162 162
 	}
163 163
 }
164 164
 
... ...
@@ -178,6 +178,6 @@ func TestVolumeContextWriteJSONField(t *testing.T) {
178 178
 		if err := json.Unmarshal([]byte(line), &s); err != nil {
179 179
 			t.Fatal(err)
180 180
 		}
181
-		assert.Equal(t, s, volumes[i].Name)
181
+		assert.Equal(t, volumes[i].Name, s)
182 182
 	}
183 183
 }
... ...
@@ -6,8 +6,8 @@ import (
6 6
 	"github.com/docker/docker/api/types/swarm"
7 7
 	// Import builders to get the builder function as package function
8 8
 	. "github.com/docker/docker/cli/internal/test/builders"
9
-	"github.com/docker/docker/pkg/testutil/assert"
10 9
 	"github.com/pkg/errors"
10
+	"github.com/stretchr/testify/assert"
11 11
 	"golang.org/x/net/context"
12 12
 )
13 13
 
... ...
@@ -21,7 +21,7 @@ func TestResolveError(t *testing.T) {
21 21
 	idResolver := New(cli, false)
22 22
 	_, err := idResolver.Resolve(context.Background(), struct{}{}, "nodeID")
23 23
 
24
-	assert.Error(t, err, "unsupported type")
24
+	assert.EqualError(t, err, "unsupported type")
25 25
 }
26 26
 
27 27
 func TestResolveWithNoResolveOption(t *testing.T) {
... ...
@@ -40,9 +40,9 @@ func TestResolveWithNoResolveOption(t *testing.T) {
40 40
 	idResolver := New(cli, true)
41 41
 	id, err := idResolver.Resolve(context.Background(), swarm.Node{}, "nodeID")
42 42
 
43
-	assert.NilError(t, err)
44
-	assert.Equal(t, id, "nodeID")
45
-	assert.Equal(t, resolved, false)
43
+	assert.NoError(t, err)
44
+	assert.Equal(t, "nodeID", id)
45
+	assert.False(t, resolved)
46 46
 }
47 47
 
48 48
 func TestResolveWithCache(t *testing.T) {
... ...
@@ -59,11 +59,11 @@ func TestResolveWithCache(t *testing.T) {
59 59
 	ctx := context.Background()
60 60
 	for i := 0; i < 2; i++ {
61 61
 		id, err := idResolver.Resolve(ctx, swarm.Node{}, "nodeID")
62
-		assert.NilError(t, err)
63
-		assert.Equal(t, id, "node-foo")
62
+		assert.NoError(t, err)
63
+		assert.Equal(t, "node-foo", id)
64 64
 	}
65 65
 
66
-	assert.Equal(t, inspectCounter, 1)
66
+	assert.Equal(t, 1, inspectCounter)
67 67
 }
68 68
 
69 69
 func TestResolveNode(t *testing.T) {
... ...
@@ -103,8 +103,8 @@ func TestResolveNode(t *testing.T) {
103 103
 		idResolver := New(cli, false)
104 104
 		id, err := idResolver.Resolve(ctx, swarm.Node{}, tc.nodeID)
105 105
 
106
-		assert.NilError(t, err)
107
-		assert.Equal(t, id, tc.expectedID)
106
+		assert.NoError(t, err)
107
+		assert.Equal(t, tc.expectedID, id)
108 108
 	}
109 109
 }
110 110
 
... ...
@@ -138,7 +138,7 @@ func TestResolveService(t *testing.T) {
138 138
 		idResolver := New(cli, false)
139 139
 		id, err := idResolver.Resolve(ctx, swarm.Service{}, tc.serviceID)
140 140
 
141
-		assert.NilError(t, err)
142
-		assert.Equal(t, id, tc.expectedID)
141
+		assert.NoError(t, err)
142
+		assert.Equal(t, tc.expectedID, id)
143 143
 	}
144 144
 }
... ...
@@ -10,7 +10,8 @@ import (
10 10
 	"github.com/pkg/errors"
11 11
 	// Import builders to get the builder function as package function
12 12
 	. "github.com/docker/docker/cli/internal/test/builders"
13
-	"github.com/docker/docker/pkg/testutil/assert"
13
+	"github.com/docker/docker/pkg/testutil"
14
+	"github.com/stretchr/testify/assert"
14 15
 )
15 16
 
16 17
 func TestNodeDemoteErrors(t *testing.T) {
... ...
@@ -47,7 +48,7 @@ func TestNodeDemoteErrors(t *testing.T) {
47 47
 			}, buf))
48 48
 		cmd.SetArgs(tc.args)
49 49
 		cmd.SetOutput(ioutil.Discard)
50
-		assert.Error(t, cmd.Execute(), tc.expectedError)
50
+		testutil.ErrorContains(t, cmd.Execute(), tc.expectedError)
51 51
 	}
52 52
 }
53 53
 
... ...
@@ -66,7 +67,7 @@ func TestNodeDemoteNoChange(t *testing.T) {
66 66
 			},
67 67
 		}, buf))
68 68
 	cmd.SetArgs([]string{"nodeID"})
69
-	assert.NilError(t, cmd.Execute())
69
+	assert.NoError(t, cmd.Execute())
70 70
 }
71 71
 
72 72
 func TestNodeDemoteMultipleNode(t *testing.T) {
... ...
@@ -84,5 +85,5 @@ func TestNodeDemoteMultipleNode(t *testing.T) {
84 84
 			},
85 85
 		}, buf))
86 86
 	cmd.SetArgs([]string{"nodeID1", "nodeID2"})
87
-	assert.NilError(t, cmd.Execute())
87
+	assert.NoError(t, cmd.Execute())
88 88
 }
... ...
@@ -12,8 +12,9 @@ import (
12 12
 	"github.com/pkg/errors"
13 13
 	// Import builders to get the builder function as package function
14 14
 	. "github.com/docker/docker/cli/internal/test/builders"
15
-	"github.com/docker/docker/pkg/testutil/assert"
15
+	"github.com/docker/docker/pkg/testutil"
16 16
 	"github.com/docker/docker/pkg/testutil/golden"
17
+	"github.com/stretchr/testify/assert"
17 18
 )
18 19
 
19 20
 func TestNodeInspectErrors(t *testing.T) {
... ...
@@ -77,7 +78,7 @@ func TestNodeInspectErrors(t *testing.T) {
77 77
 			cmd.Flags().Set(key, value)
78 78
 		}
79 79
 		cmd.SetOutput(ioutil.Discard)
80
-		assert.Error(t, cmd.Execute(), tc.expectedError)
80
+		testutil.ErrorContains(t, cmd.Execute(), tc.expectedError)
81 81
 	}
82 82
 }
83 83
 
... ...
@@ -115,9 +116,9 @@ func TestNodeInspectPretty(t *testing.T) {
115 115
 			}, buf))
116 116
 		cmd.SetArgs([]string{"nodeID"})
117 117
 		cmd.Flags().Set("pretty", "true")
118
-		assert.NilError(t, cmd.Execute())
118
+		assert.NoError(t, cmd.Execute())
119 119
 		actual := buf.String()
120 120
 		expected := golden.Get(t, []byte(actual), fmt.Sprintf("node-inspect-pretty.%s.golden", tc.name))
121
-		assert.EqualNormalizedString(t, assert.RemoveSpace, actual, string(expected))
121
+		testutil.EqualNormalizedString(t, testutil.RemoveSpace, actual, string(expected))
122 122
 	}
123 123
 }
... ...
@@ -12,7 +12,7 @@ import (
12 12
 	"github.com/pkg/errors"
13 13
 	// Import builders to get the builder function as package function
14 14
 	. "github.com/docker/docker/cli/internal/test/builders"
15
-	"github.com/docker/docker/pkg/testutil/assert"
15
+	"github.com/stretchr/testify/assert"
16 16
 )
17 17
 
18 18
 func TestNodeListErrorOnAPIFailure(t *testing.T) {
... ...
@@ -50,7 +50,7 @@ func TestNodeListErrorOnAPIFailure(t *testing.T) {
50 50
 		cli.SetConfigfile(&configfile.ConfigFile{})
51 51
 		cmd := newListCommand(cli)
52 52
 		cmd.SetOutput(ioutil.Discard)
53
-		assert.Error(t, cmd.Execute(), tc.expectedError)
53
+		assert.EqualError(t, cmd.Execute(), tc.expectedError)
54 54
 	}
55 55
 }
56 56
 
... ...
@@ -74,7 +74,7 @@ func TestNodeList(t *testing.T) {
74 74
 	}, buf)
75 75
 	cli.SetConfigfile(&configfile.ConfigFile{})
76 76
 	cmd := newListCommand(cli)
77
-	assert.NilError(t, cmd.Execute())
77
+	assert.NoError(t, cmd.Execute())
78 78
 	assert.Contains(t, buf.String(), `nodeID1 *           nodeHostname1       Ready               Active              Leader`)
79 79
 	assert.Contains(t, buf.String(), `nodeID2             nodeHostname2       Ready               Active              Reachable`)
80 80
 	assert.Contains(t, buf.String(), `nodeID3             nodeHostname3       Ready               Active`)
... ...
@@ -92,7 +92,7 @@ func TestNodeListQuietShouldOnlyPrintIDs(t *testing.T) {
92 92
 	cli.SetConfigfile(&configfile.ConfigFile{})
93 93
 	cmd := newListCommand(cli)
94 94
 	cmd.Flags().Set("quiet", "true")
95
-	assert.NilError(t, cmd.Execute())
95
+	assert.NoError(t, cmd.Execute())
96 96
 	assert.Contains(t, buf.String(), "nodeID")
97 97
 }
98 98
 
... ...
@@ -102,7 +102,7 @@ func TestNodeListContainsHostname(t *testing.T) {
102 102
 	cli := test.NewFakeCli(&fakeClient{}, buf)
103 103
 	cli.SetConfigfile(&configfile.ConfigFile{})
104 104
 	cmd := newListCommand(cli)
105
-	assert.NilError(t, cmd.Execute())
105
+	assert.NoError(t, cmd.Execute())
106 106
 	assert.Contains(t, buf.String(), "HOSTNAME")
107 107
 }
108 108
 
... ...
@@ -128,7 +128,7 @@ func TestNodeListDefaultFormat(t *testing.T) {
128 128
 		NodesFormat: "{{.ID}}: {{.Hostname}} {{.Status}}/{{.ManagerStatus}}",
129 129
 	})
130 130
 	cmd := newListCommand(cli)
131
-	assert.NilError(t, cmd.Execute())
131
+	assert.NoError(t, cmd.Execute())
132 132
 	assert.Contains(t, buf.String(), `nodeID1: nodeHostname1 Ready/Leader`)
133 133
 	assert.Contains(t, buf.String(), `nodeID2: nodeHostname2 Ready/Reachable`)
134 134
 	assert.Contains(t, buf.String(), `nodeID3: nodeHostname3 Ready`)
... ...
@@ -156,7 +156,7 @@ func TestNodeListFormat(t *testing.T) {
156 156
 	})
157 157
 	cmd := newListCommand(cli)
158 158
 	cmd.Flags().Set("format", "{{.Hostname}}: {{.ManagerStatus}}")
159
-	assert.NilError(t, cmd.Execute())
159
+	assert.NoError(t, cmd.Execute())
160 160
 	assert.Contains(t, buf.String(), `nodeHostname1: Leader`)
161 161
 	assert.Contains(t, buf.String(), `nodeHostname2: Reachable`)
162 162
 }
... ...
@@ -10,7 +10,8 @@ import (
10 10
 	"github.com/pkg/errors"
11 11
 	// Import builders to get the builder function as package function
12 12
 	. "github.com/docker/docker/cli/internal/test/builders"
13
-	"github.com/docker/docker/pkg/testutil/assert"
13
+	"github.com/docker/docker/pkg/testutil"
14
+	"github.com/stretchr/testify/assert"
14 15
 )
15 16
 
16 17
 func TestNodePromoteErrors(t *testing.T) {
... ...
@@ -47,7 +48,7 @@ func TestNodePromoteErrors(t *testing.T) {
47 47
 			}, buf))
48 48
 		cmd.SetArgs(tc.args)
49 49
 		cmd.SetOutput(ioutil.Discard)
50
-		assert.Error(t, cmd.Execute(), tc.expectedError)
50
+		testutil.ErrorContains(t, cmd.Execute(), tc.expectedError)
51 51
 	}
52 52
 }
53 53
 
... ...
@@ -66,7 +67,7 @@ func TestNodePromoteNoChange(t *testing.T) {
66 66
 			},
67 67
 		}, buf))
68 68
 	cmd.SetArgs([]string{"nodeID"})
69
-	assert.NilError(t, cmd.Execute())
69
+	assert.NoError(t, cmd.Execute())
70 70
 }
71 71
 
72 72
 func TestNodePromoteMultipleNode(t *testing.T) {
... ...
@@ -84,5 +85,5 @@ func TestNodePromoteMultipleNode(t *testing.T) {
84 84
 			},
85 85
 		}, buf))
86 86
 	cmd.SetArgs([]string{"nodeID1", "nodeID2"})
87
-	assert.NilError(t, cmd.Execute())
87
+	assert.NoError(t, cmd.Execute())
88 88
 }
... ...
@@ -13,8 +13,9 @@ import (
13 13
 	"github.com/pkg/errors"
14 14
 	// Import builders to get the builder function as package function
15 15
 	. "github.com/docker/docker/cli/internal/test/builders"
16
-	"github.com/docker/docker/pkg/testutil/assert"
16
+	"github.com/docker/docker/pkg/testutil"
17 17
 	"github.com/docker/docker/pkg/testutil/golden"
18
+	"github.com/stretchr/testify/assert"
18 19
 )
19 20
 
20 21
 func TestNodePsErrors(t *testing.T) {
... ...
@@ -62,7 +63,7 @@ func TestNodePsErrors(t *testing.T) {
62 62
 			cmd.Flags().Set(key, value)
63 63
 		}
64 64
 		cmd.SetOutput(ioutil.Discard)
65
-		assert.Error(t, cmd.Execute(), tc.expectedError)
65
+		assert.EqualError(t, cmd.Execute(), tc.expectedError)
66 66
 	}
67 67
 }
68 68
 
... ...
@@ -125,9 +126,9 @@ func TestNodePs(t *testing.T) {
125 125
 		for key, value := range tc.flags {
126 126
 			cmd.Flags().Set(key, value)
127 127
 		}
128
-		assert.NilError(t, cmd.Execute())
128
+		assert.NoError(t, cmd.Execute())
129 129
 		actual := buf.String()
130 130
 		expected := golden.Get(t, []byte(actual), fmt.Sprintf("node-ps.%s.golden", tc.name))
131
-		assert.EqualNormalizedString(t, assert.RemoveSpace, actual, string(expected))
131
+		testutil.EqualNormalizedString(t, testutil.RemoveSpace, actual, string(expected))
132 132
 	}
133 133
 }
... ...
@@ -6,8 +6,9 @@ import (
6 6
 	"testing"
7 7
 
8 8
 	"github.com/docker/docker/cli/internal/test"
9
-	"github.com/docker/docker/pkg/testutil/assert"
9
+	"github.com/docker/docker/pkg/testutil"
10 10
 	"github.com/pkg/errors"
11
+	"github.com/stretchr/testify/assert"
11 12
 )
12 13
 
13 14
 func TestNodeRemoveErrors(t *testing.T) {
... ...
@@ -35,7 +36,7 @@ func TestNodeRemoveErrors(t *testing.T) {
35 35
 			}, buf))
36 36
 		cmd.SetArgs(tc.args)
37 37
 		cmd.SetOutput(ioutil.Discard)
38
-		assert.Error(t, cmd.Execute(), tc.expectedError)
38
+		testutil.ErrorContains(t, cmd.Execute(), tc.expectedError)
39 39
 	}
40 40
 }
41 41
 
... ...
@@ -43,5 +44,5 @@ func TestNodeRemoveMultiple(t *testing.T) {
43 43
 	buf := new(bytes.Buffer)
44 44
 	cmd := newRemoveCommand(test.NewFakeCli(&fakeClient{}, buf))
45 45
 	cmd.SetArgs([]string{"nodeID1", "nodeID2"})
46
-	assert.NilError(t, cmd.Execute())
46
+	assert.NoError(t, cmd.Execute())
47 47
 }
... ...
@@ -10,7 +10,8 @@ import (
10 10
 	"github.com/pkg/errors"
11 11
 	// Import builders to get the builder function as package function
12 12
 	. "github.com/docker/docker/cli/internal/test/builders"
13
-	"github.com/docker/docker/pkg/testutil/assert"
13
+	"github.com/docker/docker/pkg/testutil"
14
+	"github.com/stretchr/testify/assert"
14 15
 )
15 16
 
16 17
 func TestNodeUpdateErrors(t *testing.T) {
... ...
@@ -67,7 +68,7 @@ func TestNodeUpdateErrors(t *testing.T) {
67 67
 			cmd.Flags().Set(key, value)
68 68
 		}
69 69
 		cmd.SetOutput(ioutil.Discard)
70
-		assert.Error(t, cmd.Execute(), tc.expectedError)
70
+		testutil.ErrorContains(t, cmd.Execute(), tc.expectedError)
71 71
 	}
72 72
 }
73 73
 
... ...
@@ -167,6 +168,6 @@ func TestNodeUpdate(t *testing.T) {
167 167
 		for key, value := range tc.flags {
168 168
 			cmd.Flags().Set(key, value)
169 169
 		}
170
-		assert.NilError(t, cmd.Execute())
170
+		assert.NoError(t, cmd.Execute())
171 171
 	}
172 172
 }
... ...
@@ -10,9 +10,10 @@ import (
10 10
 	"github.com/docker/docker/api/types"
11 11
 	"github.com/docker/docker/api/types/swarm"
12 12
 	"github.com/docker/docker/cli/internal/test"
13
-	"github.com/docker/docker/pkg/testutil/assert"
13
+	"github.com/docker/docker/pkg/testutil"
14 14
 	"github.com/docker/docker/pkg/testutil/golden"
15 15
 	"github.com/pkg/errors"
16
+	"github.com/stretchr/testify/assert"
16 17
 )
17 18
 
18 19
 const secretDataFile = "secret-create-with-name.golden"
... ...
@@ -47,7 +48,7 @@ func TestSecretCreateErrors(t *testing.T) {
47 47
 		)
48 48
 		cmd.SetArgs(tc.args)
49 49
 		cmd.SetOutput(ioutil.Discard)
50
-		assert.Error(t, cmd.Execute(), tc.expectedError)
50
+		testutil.ErrorContains(t, cmd.Execute(), tc.expectedError)
51 51
 	}
52 52
 }
53 53
 
... ...
@@ -71,10 +72,10 @@ func TestSecretCreateWithName(t *testing.T) {
71 71
 
72 72
 	cmd := newSecretCreateCommand(cli)
73 73
 	cmd.SetArgs([]string{name, filepath.Join("testdata", secretDataFile)})
74
-	assert.NilError(t, cmd.Execute())
74
+	assert.NoError(t, cmd.Execute())
75 75
 	expected := golden.Get(t, actual, secretDataFile)
76
-	assert.Equal(t, string(actual), string(expected))
77
-	assert.Equal(t, strings.TrimSpace(buf.String()), "ID-"+name)
76
+	assert.Equal(t, expected, actual)
77
+	assert.Equal(t, "ID-"+name, strings.TrimSpace(buf.String()))
78 78
 }
79 79
 
80 80
 func TestSecretCreateWithLabels(t *testing.T) {
... ...
@@ -105,8 +106,8 @@ func TestSecretCreateWithLabels(t *testing.T) {
105 105
 	cmd.SetArgs([]string{name, filepath.Join("testdata", secretDataFile)})
106 106
 	cmd.Flags().Set("label", "lbl1=Label-foo")
107 107
 	cmd.Flags().Set("label", "lbl2=Label-bar")
108
-	assert.NilError(t, cmd.Execute())
109
-	assert.Equal(t, strings.TrimSpace(buf.String()), "ID-"+name)
108
+	assert.NoError(t, cmd.Execute())
109
+	assert.Equal(t, "ID-"+name, strings.TrimSpace(buf.String()))
110 110
 }
111 111
 
112 112
 func compareMap(actual map[string]string, expected map[string]string) bool {
... ...
@@ -11,8 +11,9 @@ import (
11 11
 	"github.com/pkg/errors"
12 12
 	// Import builders to get the builder function as package function
13 13
 	. "github.com/docker/docker/cli/internal/test/builders"
14
-	"github.com/docker/docker/pkg/testutil/assert"
14
+	"github.com/docker/docker/pkg/testutil"
15 15
 	"github.com/docker/docker/pkg/testutil/golden"
16
+	"github.com/stretchr/testify/assert"
16 17
 )
17 18
 
18 19
 func TestSecretInspectErrors(t *testing.T) {
... ...
@@ -62,7 +63,7 @@ func TestSecretInspectErrors(t *testing.T) {
62 62
 			cmd.Flags().Set(key, value)
63 63
 		}
64 64
 		cmd.SetOutput(ioutil.Discard)
65
-		assert.Error(t, cmd.Execute(), tc.expectedError)
65
+		testutil.ErrorContains(t, cmd.Execute(), tc.expectedError)
66 66
 	}
67 67
 }
68 68
 
... ...
@@ -100,10 +101,10 @@ func TestSecretInspectWithoutFormat(t *testing.T) {
100 100
 			}, buf),
101 101
 		)
102 102
 		cmd.SetArgs(tc.args)
103
-		assert.NilError(t, cmd.Execute())
103
+		assert.NoError(t, cmd.Execute())
104 104
 		actual := buf.String()
105 105
 		expected := golden.Get(t, []byte(actual), fmt.Sprintf("secret-inspect-without-format.%s.golden", tc.name))
106
-		assert.EqualNormalizedString(t, assert.RemoveSpace, actual, string(expected))
106
+		testutil.EqualNormalizedString(t, testutil.RemoveSpace, actual, string(expected))
107 107
 	}
108 108
 }
109 109
 
... ...
@@ -141,9 +142,9 @@ func TestSecretInspectWithFormat(t *testing.T) {
141 141
 		)
142 142
 		cmd.SetArgs(tc.args)
143 143
 		cmd.Flags().Set("format", tc.format)
144
-		assert.NilError(t, cmd.Execute())
144
+		assert.NoError(t, cmd.Execute())
145 145
 		actual := buf.String()
146 146
 		expected := golden.Get(t, []byte(actual), fmt.Sprintf("secret-inspect-with-format.%s.golden", tc.name))
147
-		assert.EqualNormalizedString(t, assert.RemoveSpace, actual, string(expected))
147
+		testutil.EqualNormalizedString(t, testutil.RemoveSpace, actual, string(expected))
148 148
 	}
149 149
 }
... ...
@@ -13,8 +13,9 @@ import (
13 13
 	"github.com/pkg/errors"
14 14
 	// Import builders to get the builder function as package function
15 15
 	. "github.com/docker/docker/cli/internal/test/builders"
16
-	"github.com/docker/docker/pkg/testutil/assert"
16
+	"github.com/docker/docker/pkg/testutil"
17 17
 	"github.com/docker/docker/pkg/testutil/golden"
18
+	"github.com/stretchr/testify/assert"
18 19
 )
19 20
 
20 21
 func TestSecretListErrors(t *testing.T) {
... ...
@@ -43,7 +44,7 @@ func TestSecretListErrors(t *testing.T) {
43 43
 		)
44 44
 		cmd.SetArgs(tc.args)
45 45
 		cmd.SetOutput(ioutil.Discard)
46
-		assert.Error(t, cmd.Execute(), tc.expectedError)
46
+		testutil.ErrorContains(t, cmd.Execute(), tc.expectedError)
47 47
 	}
48 48
 }
49 49
 
... ...
@@ -70,10 +71,10 @@ func TestSecretList(t *testing.T) {
70 70
 	cli.SetConfigfile(&configfile.ConfigFile{})
71 71
 	cmd := newSecretListCommand(cli)
72 72
 	cmd.SetOutput(buf)
73
-	assert.NilError(t, cmd.Execute())
73
+	assert.NoError(t, cmd.Execute())
74 74
 	actual := buf.String()
75 75
 	expected := golden.Get(t, []byte(actual), "secret-list.golden")
76
-	assert.EqualNormalizedString(t, assert.RemoveSpace, actual, string(expected))
76
+	testutil.EqualNormalizedString(t, testutil.RemoveSpace, actual, string(expected))
77 77
 }
78 78
 
79 79
 func TestSecretListWithQuietOption(t *testing.T) {
... ...
@@ -91,10 +92,10 @@ func TestSecretListWithQuietOption(t *testing.T) {
91 91
 	cli.SetConfigfile(&configfile.ConfigFile{})
92 92
 	cmd := newSecretListCommand(cli)
93 93
 	cmd.Flags().Set("quiet", "true")
94
-	assert.NilError(t, cmd.Execute())
94
+	assert.NoError(t, cmd.Execute())
95 95
 	actual := buf.String()
96 96
 	expected := golden.Get(t, []byte(actual), "secret-list-with-quiet-option.golden")
97
-	assert.EqualNormalizedString(t, assert.RemoveSpace, actual, string(expected))
97
+	testutil.EqualNormalizedString(t, testutil.RemoveSpace, actual, string(expected))
98 98
 }
99 99
 
100 100
 func TestSecretListWithConfigFormat(t *testing.T) {
... ...
@@ -113,10 +114,10 @@ func TestSecretListWithConfigFormat(t *testing.T) {
113 113
 		SecretFormat: "{{ .Name }} {{ .Labels }}",
114 114
 	})
115 115
 	cmd := newSecretListCommand(cli)
116
-	assert.NilError(t, cmd.Execute())
116
+	assert.NoError(t, cmd.Execute())
117 117
 	actual := buf.String()
118 118
 	expected := golden.Get(t, []byte(actual), "secret-list-with-config-format.golden")
119
-	assert.EqualNormalizedString(t, assert.RemoveSpace, actual, string(expected))
119
+	testutil.EqualNormalizedString(t, testutil.RemoveSpace, actual, string(expected))
120 120
 }
121 121
 
122 122
 func TestSecretListWithFormat(t *testing.T) {
... ...
@@ -133,18 +134,18 @@ func TestSecretListWithFormat(t *testing.T) {
133 133
 	}, buf)
134 134
 	cmd := newSecretListCommand(cli)
135 135
 	cmd.Flags().Set("format", "{{ .Name }} {{ .Labels }}")
136
-	assert.NilError(t, cmd.Execute())
136
+	assert.NoError(t, cmd.Execute())
137 137
 	actual := buf.String()
138 138
 	expected := golden.Get(t, []byte(actual), "secret-list-with-format.golden")
139
-	assert.EqualNormalizedString(t, assert.RemoveSpace, actual, string(expected))
139
+	testutil.EqualNormalizedString(t, testutil.RemoveSpace, actual, string(expected))
140 140
 }
141 141
 
142 142
 func TestSecretListWithFilter(t *testing.T) {
143 143
 	buf := new(bytes.Buffer)
144 144
 	cli := test.NewFakeCli(&fakeClient{
145 145
 		secretListFunc: func(options types.SecretListOptions) ([]swarm.Secret, error) {
146
-			assert.Equal(t, options.Filters.Get("name")[0], "foo")
147
-			assert.Equal(t, options.Filters.Get("label")[0], "lbl1=Label-bar")
146
+			assert.Equal(t, "foo", options.Filters.Get("name")[0], "foo")
147
+			assert.Equal(t, "lbl1=Label-bar", options.Filters.Get("label")[0])
148 148
 			return []swarm.Secret{
149 149
 				*Secret(SecretID("ID-foo"),
150 150
 					SecretName("foo"),
... ...
@@ -165,8 +166,8 @@ func TestSecretListWithFilter(t *testing.T) {
165 165
 	cmd := newSecretListCommand(cli)
166 166
 	cmd.Flags().Set("filter", "name=foo")
167 167
 	cmd.Flags().Set("filter", "label=lbl1=Label-bar")
168
-	assert.NilError(t, cmd.Execute())
168
+	assert.NoError(t, cmd.Execute())
169 169
 	actual := buf.String()
170 170
 	expected := golden.Get(t, []byte(actual), "secret-list-with-filter.golden")
171
-	assert.EqualNormalizedString(t, assert.RemoveSpace, actual, string(expected))
171
+	testutil.EqualNormalizedString(t, testutil.RemoveSpace, actual, string(expected))
172 172
 }
... ...
@@ -7,8 +7,9 @@ import (
7 7
 	"testing"
8 8
 
9 9
 	"github.com/docker/docker/cli/internal/test"
10
-	"github.com/docker/docker/pkg/testutil/assert"
10
+	"github.com/docker/docker/pkg/testutil"
11 11
 	"github.com/pkg/errors"
12
+	"github.com/stretchr/testify/assert"
12 13
 )
13 14
 
14 15
 func TestSecretRemoveErrors(t *testing.T) {
... ...
@@ -38,7 +39,7 @@ func TestSecretRemoveErrors(t *testing.T) {
38 38
 		)
39 39
 		cmd.SetArgs(tc.args)
40 40
 		cmd.SetOutput(ioutil.Discard)
41
-		assert.Error(t, cmd.Execute(), tc.expectedError)
41
+		testutil.ErrorContains(t, cmd.Execute(), tc.expectedError)
42 42
 	}
43 43
 }
44 44
 
... ...
@@ -54,9 +55,9 @@ func TestSecretRemoveWithName(t *testing.T) {
54 54
 	}, buf)
55 55
 	cmd := newSecretRemoveCommand(cli)
56 56
 	cmd.SetArgs(names)
57
-	assert.NilError(t, cmd.Execute())
58
-	assert.EqualStringSlice(t, strings.Split(strings.TrimSpace(buf.String()), "\n"), names)
59
-	assert.EqualStringSlice(t, removedSecrets, names)
57
+	assert.NoError(t, cmd.Execute())
58
+	assert.Equal(t, names, strings.Split(strings.TrimSpace(buf.String()), "\n"))
59
+	assert.Equal(t, names, removedSecrets)
60 60
 }
61 61
 
62 62
 func TestSecretRemoveContinueAfterError(t *testing.T) {
... ...
@@ -76,6 +77,6 @@ func TestSecretRemoveContinueAfterError(t *testing.T) {
76 76
 
77 77
 	cmd := newSecretRemoveCommand(cli)
78 78
 	cmd.SetArgs(names)
79
-	assert.Error(t, cmd.Execute(), "error removing secret: foo")
80
-	assert.EqualStringSlice(t, removedSecrets, names)
79
+	assert.EqualError(t, cmd.Execute(), "error removing secret: foo")
80
+	assert.Equal(t, names, removedSecrets)
81 81
 }
... ...
@@ -10,7 +10,7 @@ import (
10 10
 	"github.com/docker/docker/api/types"
11 11
 	"github.com/docker/docker/api/types/swarm"
12 12
 	"github.com/docker/docker/cli/command/formatter"
13
-	"github.com/docker/docker/pkg/testutil/assert"
13
+	"github.com/stretchr/testify/assert"
14 14
 )
15 15
 
16 16
 func formatServiceInspect(t *testing.T, format formatter.Format, now time.Time) string {
... ...
@@ -136,5 +136,5 @@ func TestJSONFormatWithNoUpdateConfig(t *testing.T) {
136 136
 		t.Fatal(err)
137 137
 	}
138 138
 	t.Logf("m2=%+v", m2)
139
-	assert.DeepEqual(t, m2, m1)
139
+	assert.Equal(t, m1, m2)
140 140
 }
... ...
@@ -1,71 +1,70 @@
1 1
 package service
2 2
 
3 3
 import (
4
-	"reflect"
5 4
 	"testing"
6 5
 	"time"
7 6
 
8 7
 	"github.com/docker/docker/api/types/container"
9 8
 	"github.com/docker/docker/opts"
10
-	"github.com/docker/docker/pkg/testutil/assert"
9
+	"github.com/stretchr/testify/assert"
11 10
 )
12 11
 
13 12
 func TestMemBytesString(t *testing.T) {
14 13
 	var mem opts.MemBytes = 1048576
15
-	assert.Equal(t, mem.String(), "1MiB")
14
+	assert.Equal(t, "1MiB", mem.String())
16 15
 }
17 16
 
18 17
 func TestMemBytesSetAndValue(t *testing.T) {
19 18
 	var mem opts.MemBytes
20
-	assert.NilError(t, mem.Set("5kb"))
21
-	assert.Equal(t, mem.Value(), int64(5120))
19
+	assert.NoError(t, mem.Set("5kb"))
20
+	assert.Equal(t, int64(5120), mem.Value())
22 21
 }
23 22
 
24 23
 func TestNanoCPUsString(t *testing.T) {
25 24
 	var cpus opts.NanoCPUs = 6100000000
26
-	assert.Equal(t, cpus.String(), "6.100")
25
+	assert.Equal(t, "6.100", cpus.String())
27 26
 }
28 27
 
29 28
 func TestNanoCPUsSetAndValue(t *testing.T) {
30 29
 	var cpus opts.NanoCPUs
31
-	assert.NilError(t, cpus.Set("0.35"))
32
-	assert.Equal(t, cpus.Value(), int64(350000000))
30
+	assert.NoError(t, cpus.Set("0.35"))
31
+	assert.Equal(t, int64(350000000), cpus.Value())
33 32
 }
34 33
 
35 34
 func TestDurationOptString(t *testing.T) {
36 35
 	dur := time.Duration(300 * 10e8)
37 36
 	duration := DurationOpt{value: &dur}
38
-	assert.Equal(t, duration.String(), "5m0s")
37
+	assert.Equal(t, "5m0s", duration.String())
39 38
 }
40 39
 
41 40
 func TestDurationOptSetAndValue(t *testing.T) {
42 41
 	var duration DurationOpt
43
-	assert.NilError(t, duration.Set("300s"))
44
-	assert.Equal(t, *duration.Value(), time.Duration(300*10e8))
45
-	assert.NilError(t, duration.Set("-300s"))
46
-	assert.Equal(t, *duration.Value(), time.Duration(-300*10e8))
42
+	assert.NoError(t, duration.Set("300s"))
43
+	assert.Equal(t, time.Duration(300*10e8), *duration.Value())
44
+	assert.NoError(t, duration.Set("-300s"))
45
+	assert.Equal(t, time.Duration(-300*10e8), *duration.Value())
47 46
 }
48 47
 
49 48
 func TestPositiveDurationOptSetAndValue(t *testing.T) {
50 49
 	var duration PositiveDurationOpt
51
-	assert.NilError(t, duration.Set("300s"))
52
-	assert.Equal(t, *duration.Value(), time.Duration(300*10e8))
53
-	assert.Error(t, duration.Set("-300s"), "cannot be negative")
50
+	assert.NoError(t, duration.Set("300s"))
51
+	assert.Equal(t, time.Duration(300*10e8), *duration.Value())
52
+	assert.EqualError(t, duration.Set("-300s"), "duration cannot be negative")
54 53
 }
55 54
 
56 55
 func TestUint64OptString(t *testing.T) {
57 56
 	value := uint64(2345678)
58 57
 	opt := Uint64Opt{value: &value}
59
-	assert.Equal(t, opt.String(), "2345678")
58
+	assert.Equal(t, "2345678", opt.String())
60 59
 
61 60
 	opt = Uint64Opt{}
62
-	assert.Equal(t, opt.String(), "")
61
+	assert.Equal(t, "", opt.String())
63 62
 }
64 63
 
65 64
 func TestUint64OptSetAndValue(t *testing.T) {
66 65
 	var opt Uint64Opt
67
-	assert.NilError(t, opt.Set("14445"))
68
-	assert.Equal(t, *opt.Value(), uint64(14445))
66
+	assert.NoError(t, opt.Set("14445"))
67
+	assert.Equal(t, uint64(14445), *opt.Value())
69 68
 }
70 69
 
71 70
 func TestHealthCheckOptionsToHealthConfig(t *testing.T) {
... ...
@@ -78,14 +77,14 @@ func TestHealthCheckOptionsToHealthConfig(t *testing.T) {
78 78
 		retries:     10,
79 79
 	}
80 80
 	config, err := opt.toHealthConfig()
81
-	assert.NilError(t, err)
82
-	assert.Equal(t, reflect.DeepEqual(config, &container.HealthConfig{
81
+	assert.NoError(t, err)
82
+	assert.Equal(t, &container.HealthConfig{
83 83
 		Test:        []string{"CMD-SHELL", "curl"},
84 84
 		Interval:    time.Second,
85 85
 		Timeout:     time.Second,
86 86
 		StartPeriod: time.Second,
87 87
 		Retries:     10,
88
-	}), true)
88
+	}, config)
89 89
 }
90 90
 
91 91
 func TestHealthCheckOptionsToHealthConfigNoHealthcheck(t *testing.T) {
... ...
@@ -93,10 +92,10 @@ func TestHealthCheckOptionsToHealthConfigNoHealthcheck(t *testing.T) {
93 93
 		noHealthcheck: true,
94 94
 	}
95 95
 	config, err := opt.toHealthConfig()
96
-	assert.NilError(t, err)
97
-	assert.Equal(t, reflect.DeepEqual(config, &container.HealthConfig{
96
+	assert.NoError(t, err)
97
+	assert.Equal(t, &container.HealthConfig{
98 98
 		Test: []string{"NONE"},
99
-	}), true)
99
+	}, config)
100 100
 }
101 101
 
102 102
 func TestHealthCheckOptionsToHealthConfigConflict(t *testing.T) {
... ...
@@ -105,5 +104,5 @@ func TestHealthCheckOptionsToHealthConfigConflict(t *testing.T) {
105 105
 		noHealthcheck: true,
106 106
 	}
107 107
 	_, err := opt.toHealthConfig()
108
-	assert.Error(t, err, "--no-healthcheck conflicts with --health-* options")
108
+	assert.EqualError(t, err, "--no-healthcheck conflicts with --health-* options")
109 109
 }
... ...
@@ -10,7 +10,8 @@ import (
10 10
 	"github.com/docker/docker/api/types/container"
11 11
 	mounttypes "github.com/docker/docker/api/types/mount"
12 12
 	"github.com/docker/docker/api/types/swarm"
13
-	"github.com/docker/docker/pkg/testutil/assert"
13
+	"github.com/stretchr/testify/assert"
14
+	"github.com/stretchr/testify/require"
14 15
 	"golang.org/x/net/context"
15 16
 )
16 17
 
... ...
@@ -23,7 +24,7 @@ func TestUpdateServiceArgs(t *testing.T) {
23 23
 	cspec.Args = []string{"old", "args"}
24 24
 
25 25
 	updateService(nil, nil, flags, spec)
26
-	assert.EqualStringSlice(t, cspec.Args, []string{"the", "new args"})
26
+	assert.Equal(t, []string{"the", "new args"}, cspec.Args)
27 27
 }
28 28
 
29 29
 func TestUpdateLabels(t *testing.T) {
... ...
@@ -37,9 +38,9 @@ func TestUpdateLabels(t *testing.T) {
37 37
 	}
38 38
 
39 39
 	updateLabels(flags, &labels)
40
-	assert.Equal(t, len(labels), 2)
41
-	assert.Equal(t, labels["tokeep"], "value")
42
-	assert.Equal(t, labels["toadd"], "newlabel")
40
+	assert.Len(t, labels, 2)
41
+	assert.Equal(t, "value", labels["tokeep"])
42
+	assert.Equal(t, "newlabel", labels["toadd"])
43 43
 }
44 44
 
45 45
 func TestUpdateLabelsRemoveALabelThatDoesNotExist(t *testing.T) {
... ...
@@ -48,7 +49,7 @@ func TestUpdateLabelsRemoveALabelThatDoesNotExist(t *testing.T) {
48 48
 
49 49
 	labels := map[string]string{"foo": "theoldlabel"}
50 50
 	updateLabels(flags, &labels)
51
-	assert.Equal(t, len(labels), 1)
51
+	assert.Len(t, labels, 1)
52 52
 }
53 53
 
54 54
 func TestUpdatePlacementConstraints(t *testing.T) {
... ...
@@ -61,9 +62,9 @@ func TestUpdatePlacementConstraints(t *testing.T) {
61 61
 	}
62 62
 
63 63
 	updatePlacementConstraints(flags, placement)
64
-	assert.Equal(t, len(placement.Constraints), 2)
65
-	assert.Equal(t, placement.Constraints[0], "container=tokeep")
66
-	assert.Equal(t, placement.Constraints[1], "node=toadd")
64
+	require.Len(t, placement.Constraints, 2)
65
+	assert.Equal(t, "container=tokeep", placement.Constraints[0])
66
+	assert.Equal(t, "node=toadd", placement.Constraints[1])
67 67
 }
68 68
 
69 69
 func TestUpdatePlacementPrefs(t *testing.T) {
... ...
@@ -87,9 +88,9 @@ func TestUpdatePlacementPrefs(t *testing.T) {
87 87
 	}
88 88
 
89 89
 	updatePlacementPreferences(flags, placement)
90
-	assert.Equal(t, len(placement.Preferences), 2)
91
-	assert.Equal(t, placement.Preferences[0].Spread.SpreadDescriptor, "node.labels.row")
92
-	assert.Equal(t, placement.Preferences[1].Spread.SpreadDescriptor, "node.labels.dc")
90
+	require.Len(t, placement.Preferences, 2)
91
+	assert.Equal(t, "node.labels.row", placement.Preferences[0].Spread.SpreadDescriptor)
92
+	assert.Equal(t, "node.labels.dc", placement.Preferences[1].Spread.SpreadDescriptor)
93 93
 }
94 94
 
95 95
 func TestUpdateEnvironment(t *testing.T) {
... ...
@@ -100,11 +101,11 @@ func TestUpdateEnvironment(t *testing.T) {
100 100
 	envs := []string{"toremove=theenvtoremove", "tokeep=value"}
101 101
 
102 102
 	updateEnvironment(flags, &envs)
103
-	assert.Equal(t, len(envs), 2)
103
+	require.Len(t, envs, 2)
104 104
 	// Order has been removed in updateEnvironment (map)
105 105
 	sort.Strings(envs)
106
-	assert.Equal(t, envs[0], "toadd=newenv")
107
-	assert.Equal(t, envs[1], "tokeep=value")
106
+	assert.Equal(t, "toadd=newenv", envs[0])
107
+	assert.Equal(t, "tokeep=value", envs[1])
108 108
 }
109 109
 
110 110
 func TestUpdateEnvironmentWithDuplicateValues(t *testing.T) {
... ...
@@ -116,7 +117,7 @@ func TestUpdateEnvironmentWithDuplicateValues(t *testing.T) {
116 116
 	envs := []string{"foo=value"}
117 117
 
118 118
 	updateEnvironment(flags, &envs)
119
-	assert.Equal(t, len(envs), 0)
119
+	assert.Len(t, envs, 0)
120 120
 }
121 121
 
122 122
 func TestUpdateEnvironmentWithDuplicateKeys(t *testing.T) {
... ...
@@ -127,8 +128,8 @@ func TestUpdateEnvironmentWithDuplicateKeys(t *testing.T) {
127 127
 	envs := []string{"A=c"}
128 128
 
129 129
 	updateEnvironment(flags, &envs)
130
-	assert.Equal(t, len(envs), 1)
131
-	assert.Equal(t, envs[0], "A=b")
130
+	require.Len(t, envs, 1)
131
+	assert.Equal(t, "A=b", envs[0])
132 132
 }
133 133
 
134 134
 func TestUpdateGroups(t *testing.T) {
... ...
@@ -142,10 +143,10 @@ func TestUpdateGroups(t *testing.T) {
142 142
 	groups := []string{"bar", "root"}
143 143
 
144 144
 	updateGroups(flags, &groups)
145
-	assert.Equal(t, len(groups), 3)
146
-	assert.Equal(t, groups[0], "bar")
147
-	assert.Equal(t, groups[1], "foo")
148
-	assert.Equal(t, groups[2], "wheel")
145
+	require.Len(t, groups, 3)
146
+	assert.Equal(t, "bar", groups[0])
147
+	assert.Equal(t, "foo", groups[1])
148
+	assert.Equal(t, "wheel", groups[2])
149 149
 }
150 150
 
151 151
 func TestUpdateDNSConfig(t *testing.T) {
... ...
@@ -160,7 +161,7 @@ func TestUpdateDNSConfig(t *testing.T) {
160 160
 	// IPv6
161 161
 	flags.Set("dns-add", "2001:db8:abc8::1")
162 162
 	// Invalid dns record
163
-	assert.Error(t, flags.Set("dns-add", "x.y.z.w"), "x.y.z.w is not an ip address")
163
+	assert.EqualError(t, flags.Set("dns-add", "x.y.z.w"), "x.y.z.w is not an ip address")
164 164
 
165 165
 	// domains with duplicates
166 166
 	flags.Set("dns-search-add", "example.com")
... ...
@@ -168,7 +169,7 @@ func TestUpdateDNSConfig(t *testing.T) {
168 168
 	flags.Set("dns-search-add", "example.org")
169 169
 	flags.Set("dns-search-rm", "example.org")
170 170
 	// Invalid dns search domain
171
-	assert.Error(t, flags.Set("dns-search-add", "example$com"), "example$com is not a valid domain")
171
+	assert.EqualError(t, flags.Set("dns-search-add", "example$com"), "example$com is not a valid domain")
172 172
 
173 173
 	flags.Set("dns-option-add", "ndots:9")
174 174
 	flags.Set("dns-option-rm", "timeout:3")
... ...
@@ -181,16 +182,16 @@ func TestUpdateDNSConfig(t *testing.T) {
181 181
 
182 182
 	updateDNSConfig(flags, &config)
183 183
 
184
-	assert.Equal(t, len(config.Nameservers), 3)
185
-	assert.Equal(t, config.Nameservers[0], "1.1.1.1")
186
-	assert.Equal(t, config.Nameservers[1], "2001:db8:abc8::1")
187
-	assert.Equal(t, config.Nameservers[2], "5.5.5.5")
184
+	require.Len(t, config.Nameservers, 3)
185
+	assert.Equal(t, "1.1.1.1", config.Nameservers[0])
186
+	assert.Equal(t, "2001:db8:abc8::1", config.Nameservers[1])
187
+	assert.Equal(t, "5.5.5.5", config.Nameservers[2])
188 188
 
189
-	assert.Equal(t, len(config.Search), 2)
190
-	assert.Equal(t, config.Search[0], "example.com")
191
-	assert.Equal(t, config.Search[1], "localdomain")
189
+	require.Len(t, config.Search, 2)
190
+	assert.Equal(t, "example.com", config.Search[0])
191
+	assert.Equal(t, "localdomain", config.Search[1])
192 192
 
193
-	assert.Equal(t, len(config.Options), 1)
193
+	require.Len(t, config.Options, 1)
194 194
 	assert.Equal(t, config.Options[0], "ndots:9")
195 195
 }
196 196
 
... ...
@@ -205,10 +206,9 @@ func TestUpdateMounts(t *testing.T) {
205 205
 	}
206 206
 
207 207
 	updateMounts(flags, &mounts)
208
-	assert.Equal(t, len(mounts), 2)
209
-	assert.Equal(t, mounts[0].Target, "/toadd")
210
-	assert.Equal(t, mounts[1].Target, "/tokeep")
211
-
208
+	require.Len(t, mounts, 2)
209
+	assert.Equal(t, "/toadd", mounts[0].Target)
210
+	assert.Equal(t, "/tokeep", mounts[1].Target)
212 211
 }
213 212
 
214 213
 func TestUpdateMountsWithDuplicateMounts(t *testing.T) {
... ...
@@ -222,10 +222,10 @@ func TestUpdateMountsWithDuplicateMounts(t *testing.T) {
222 222
 	}
223 223
 
224 224
 	updateMounts(flags, &mounts)
225
-	assert.Equal(t, len(mounts), 3)
226
-	assert.Equal(t, mounts[0].Target, "/tokeep1")
227
-	assert.Equal(t, mounts[1].Target, "/tokeep2")
228
-	assert.Equal(t, mounts[2].Target, "/toadd")
225
+	require.Len(t, mounts, 3)
226
+	assert.Equal(t, "/tokeep1", mounts[0].Target)
227
+	assert.Equal(t, "/tokeep2", mounts[1].Target)
228
+	assert.Equal(t, "/toadd", mounts[2].Target)
229 229
 }
230 230
 
231 231
 func TestUpdatePorts(t *testing.T) {
... ...
@@ -239,13 +239,13 @@ func TestUpdatePorts(t *testing.T) {
239 239
 	}
240 240
 
241 241
 	err := updatePorts(flags, &portConfigs)
242
-	assert.Equal(t, err, nil)
243
-	assert.Equal(t, len(portConfigs), 2)
242
+	assert.NoError(t, err)
243
+	require.Len(t, portConfigs, 2)
244 244
 	// Do a sort to have the order (might have changed by map)
245 245
 	targetPorts := []int{int(portConfigs[0].TargetPort), int(portConfigs[1].TargetPort)}
246 246
 	sort.Ints(targetPorts)
247
-	assert.Equal(t, targetPorts[0], 555)
248
-	assert.Equal(t, targetPorts[1], 1000)
247
+	assert.Equal(t, 555, targetPorts[0])
248
+	assert.Equal(t, 1000, targetPorts[1])
249 249
 }
250 250
 
251 251
 func TestUpdatePortsDuplicate(t *testing.T) {
... ...
@@ -263,9 +263,9 @@ func TestUpdatePortsDuplicate(t *testing.T) {
263 263
 	}
264 264
 
265 265
 	err := updatePorts(flags, &portConfigs)
266
-	assert.Equal(t, err, nil)
267
-	assert.Equal(t, len(portConfigs), 1)
268
-	assert.Equal(t, portConfigs[0].TargetPort, uint32(80))
266
+	assert.NoError(t, err)
267
+	require.Len(t, portConfigs, 1)
268
+	assert.Equal(t, uint32(80), portConfigs[0].TargetPort)
269 269
 }
270 270
 
271 271
 func TestUpdateHealthcheckTable(t *testing.T) {
... ...
@@ -339,9 +339,9 @@ func TestUpdateHealthcheckTable(t *testing.T) {
339 339
 		}
340 340
 		err := updateHealthcheck(flags, cspec)
341 341
 		if c.err != "" {
342
-			assert.Error(t, err, c.err)
342
+			assert.EqualError(t, err, c.err)
343 343
 		} else {
344
-			assert.NilError(t, err)
344
+			assert.NoError(t, err)
345 345
 			if !reflect.DeepEqual(cspec.Healthcheck, c.expected) {
346 346
 				t.Errorf("incorrect result for test %d, expected health config:\n\t%#v\ngot:\n\t%#v", i, c.expected, cspec.Healthcheck)
347 347
 			}
... ...
@@ -358,15 +358,15 @@ func TestUpdateHosts(t *testing.T) {
358 358
 	// just hostname should work as well
359 359
 	flags.Set("host-rm", "example.net")
360 360
 	// bad format error
361
-	assert.Error(t, flags.Set("host-add", "$example.com$"), "bad format for add-host:")
361
+	assert.EqualError(t, flags.Set("host-add", "$example.com$"), `bad format for add-host: "$example.com$"`)
362 362
 
363 363
 	hosts := []string{"1.2.3.4 example.com", "4.3.2.1 example.org", "2001:db8:abc8::1 example.net"}
364 364
 
365 365
 	updateHosts(flags, &hosts)
366
-	assert.Equal(t, len(hosts), 3)
367
-	assert.Equal(t, hosts[0], "1.2.3.4 example.com")
368
-	assert.Equal(t, hosts[1], "2001:db8:abc8::1 ipv6.net")
369
-	assert.Equal(t, hosts[2], "4.3.2.1 example.org")
366
+	require.Len(t, hosts, 3)
367
+	assert.Equal(t, "1.2.3.4 example.com", hosts[0])
368
+	assert.Equal(t, "2001:db8:abc8::1 ipv6.net", hosts[1])
369
+	assert.Equal(t, "4.3.2.1 example.org", hosts[2])
370 370
 }
371 371
 
372 372
 func TestUpdatePortsRmWithProtocol(t *testing.T) {
... ...
@@ -387,10 +387,10 @@ func TestUpdatePortsRmWithProtocol(t *testing.T) {
387 387
 	}
388 388
 
389 389
 	err := updatePorts(flags, &portConfigs)
390
-	assert.Equal(t, err, nil)
391
-	assert.Equal(t, len(portConfigs), 2)
392
-	assert.Equal(t, portConfigs[0].TargetPort, uint32(81))
393
-	assert.Equal(t, portConfigs[1].TargetPort, uint32(82))
390
+	assert.NoError(t, err)
391
+	require.Len(t, portConfigs, 2)
392
+	assert.Equal(t, uint32(81), portConfigs[0].TargetPort)
393
+	assert.Equal(t, uint32(82), portConfigs[1].TargetPort)
394 394
 }
395 395
 
396 396
 type secretAPIClientMock struct {
... ...
@@ -444,11 +444,11 @@ func TestUpdateSecretUpdateInPlace(t *testing.T) {
444 444
 
445 445
 	updatedSecrets, err := getUpdatedSecrets(apiClient, flags, secrets)
446 446
 
447
-	assert.Equal(t, err, nil)
448
-	assert.Equal(t, len(updatedSecrets), 1)
449
-	assert.Equal(t, updatedSecrets[0].SecretID, "tn9qiblgnuuut11eufquw5dev")
450
-	assert.Equal(t, updatedSecrets[0].SecretName, "foo")
451
-	assert.Equal(t, updatedSecrets[0].File.Name, "foo2")
447
+	assert.NoError(t, err)
448
+	require.Len(t, updatedSecrets, 1)
449
+	assert.Equal(t, "tn9qiblgnuuut11eufquw5dev", updatedSecrets[0].SecretID)
450
+	assert.Equal(t, "foo", updatedSecrets[0].SecretName)
451
+	assert.Equal(t, "foo2", updatedSecrets[0].File.Name)
452 452
 }
453 453
 
454 454
 func TestUpdateReadOnly(t *testing.T) {
... ...
@@ -459,18 +459,18 @@ func TestUpdateReadOnly(t *testing.T) {
459 459
 	flags := newUpdateCommand(nil).Flags()
460 460
 	flags.Set("read-only", "true")
461 461
 	updateService(nil, nil, flags, spec)
462
-	assert.Equal(t, cspec.ReadOnly, true)
462
+	assert.True(t, cspec.ReadOnly)
463 463
 
464 464
 	// Update without --read-only, no change
465 465
 	flags = newUpdateCommand(nil).Flags()
466 466
 	updateService(nil, nil, flags, spec)
467
-	assert.Equal(t, cspec.ReadOnly, true)
467
+	assert.True(t, cspec.ReadOnly)
468 468
 
469 469
 	// Update with --read-only=false, changed to false
470 470
 	flags = newUpdateCommand(nil).Flags()
471 471
 	flags.Set("read-only", "false")
472 472
 	updateService(nil, nil, flags, spec)
473
-	assert.Equal(t, cspec.ReadOnly, false)
473
+	assert.False(t, cspec.ReadOnly)
474 474
 }
475 475
 
476 476
 func TestUpdateStopSignal(t *testing.T) {
... ...
@@ -481,16 +481,16 @@ func TestUpdateStopSignal(t *testing.T) {
481 481
 	flags := newUpdateCommand(nil).Flags()
482 482
 	flags.Set("stop-signal", "SIGUSR1")
483 483
 	updateService(nil, nil, flags, spec)
484
-	assert.Equal(t, cspec.StopSignal, "SIGUSR1")
484
+	assert.Equal(t, "SIGUSR1", cspec.StopSignal)
485 485
 
486 486
 	// Update without --stop-signal, no change
487 487
 	flags = newUpdateCommand(nil).Flags()
488 488
 	updateService(nil, nil, flags, spec)
489
-	assert.Equal(t, cspec.StopSignal, "SIGUSR1")
489
+	assert.Equal(t, "SIGUSR1", cspec.StopSignal)
490 490
 
491 491
 	// Update with --stop-signal=SIGWINCH
492 492
 	flags = newUpdateCommand(nil).Flags()
493 493
 	flags.Set("stop-signal", "SIGWINCH")
494 494
 	updateService(nil, nil, flags, spec)
495
-	assert.Equal(t, cspec.StopSignal, "SIGWINCH")
495
+	assert.Equal(t, "SIGWINCH", cspec.StopSignal)
496 496
 }
... ...
@@ -6,7 +6,7 @@ import (
6 6
 
7 7
 	"github.com/docker/docker/cli/compose/convert"
8 8
 	"github.com/docker/docker/cli/internal/test"
9
-	"github.com/docker/docker/pkg/testutil/assert"
9
+	"github.com/stretchr/testify/assert"
10 10
 	"golang.org/x/net/context"
11 11
 )
12 12
 
... ...
@@ -23,5 +23,5 @@ func TestPruneServices(t *testing.T) {
23 23
 
24 24
 	pruneServices(ctx, dockerCli, namespace, services)
25 25
 
26
-	assert.DeepEqual(t, client.removedServices, buildObjectIDs([]string{objectName("foo", "remove")}))
26
+	assert.Equal(t, buildObjectIDs([]string{objectName("foo", "remove")}), client.removedServices)
27 27
 }
... ...
@@ -7,7 +7,7 @@ import (
7 7
 	"testing"
8 8
 
9 9
 	"github.com/docker/docker/cli/internal/test"
10
-	"github.com/docker/docker/pkg/testutil/assert"
10
+	"github.com/stretchr/testify/assert"
11 11
 )
12 12
 
13 13
 func TestRemoveStack(t *testing.T) {
... ...
@@ -17,20 +17,20 @@ func TestRemoveStack(t *testing.T) {
17 17
 		objectName("bar", "service1"),
18 18
 		objectName("bar", "service2"),
19 19
 	}
20
-	allServicesIDs := buildObjectIDs(allServices)
20
+	allServiceIDs := buildObjectIDs(allServices)
21 21
 
22 22
 	allNetworks := []string{
23 23
 		objectName("foo", "network1"),
24 24
 		objectName("bar", "network1"),
25 25
 	}
26
-	allNetworksIDs := buildObjectIDs(allNetworks)
26
+	allNetworkIDs := buildObjectIDs(allNetworks)
27 27
 
28 28
 	allSecrets := []string{
29 29
 		objectName("foo", "secret1"),
30 30
 		objectName("foo", "secret2"),
31 31
 		objectName("bar", "secret1"),
32 32
 	}
33
-	allSecretsIDs := buildObjectIDs(allSecrets)
33
+	allSecretIDs := buildObjectIDs(allSecrets)
34 34
 
35 35
 	cli := &fakeClient{
36 36
 		services: allServices,
... ...
@@ -40,22 +40,22 @@ func TestRemoveStack(t *testing.T) {
40 40
 	cmd := newRemoveCommand(test.NewFakeCli(cli, &bytes.Buffer{}))
41 41
 	cmd.SetArgs([]string{"foo", "bar"})
42 42
 
43
-	assert.NilError(t, cmd.Execute())
44
-	assert.DeepEqual(t, cli.removedServices, allServicesIDs)
45
-	assert.DeepEqual(t, cli.removedNetworks, allNetworksIDs)
46
-	assert.DeepEqual(t, cli.removedSecrets, allSecretsIDs)
43
+	assert.NoError(t, cmd.Execute())
44
+	assert.Equal(t, allServiceIDs, cli.removedServices)
45
+	assert.Equal(t, allNetworkIDs, cli.removedNetworks)
46
+	assert.Equal(t, allSecretIDs, cli.removedSecrets)
47 47
 }
48 48
 
49 49
 func TestSkipEmptyStack(t *testing.T) {
50 50
 	buf := new(bytes.Buffer)
51 51
 	allServices := []string{objectName("bar", "service1"), objectName("bar", "service2")}
52
-	allServicesIDs := buildObjectIDs(allServices)
52
+	allServiceIDs := buildObjectIDs(allServices)
53 53
 
54 54
 	allNetworks := []string{objectName("bar", "network1")}
55
-	allNetworksIDs := buildObjectIDs(allNetworks)
55
+	allNetworkIDs := buildObjectIDs(allNetworks)
56 56
 
57 57
 	allSecrets := []string{objectName("bar", "secret1")}
58
-	allSecretsIDs := buildObjectIDs(allSecrets)
58
+	allSecretIDs := buildObjectIDs(allSecrets)
59 59
 
60 60
 	cli := &fakeClient{
61 61
 		services: allServices,
... ...
@@ -65,22 +65,22 @@ func TestSkipEmptyStack(t *testing.T) {
65 65
 	cmd := newRemoveCommand(test.NewFakeCli(cli, buf))
66 66
 	cmd.SetArgs([]string{"foo", "bar"})
67 67
 
68
-	assert.NilError(t, cmd.Execute())
68
+	assert.NoError(t, cmd.Execute())
69 69
 	assert.Contains(t, buf.String(), "Nothing found in stack: foo")
70
-	assert.DeepEqual(t, cli.removedServices, allServicesIDs)
71
-	assert.DeepEqual(t, cli.removedNetworks, allNetworksIDs)
72
-	assert.DeepEqual(t, cli.removedSecrets, allSecretsIDs)
70
+	assert.Equal(t, allServiceIDs, cli.removedServices)
71
+	assert.Equal(t, allNetworkIDs, cli.removedNetworks)
72
+	assert.Equal(t, allSecretIDs, cli.removedSecrets)
73 73
 }
74 74
 
75 75
 func TestContinueAfterError(t *testing.T) {
76 76
 	allServices := []string{objectName("foo", "service1"), objectName("bar", "service1")}
77
-	allServicesIDs := buildObjectIDs(allServices)
77
+	allServiceIDs := buildObjectIDs(allServices)
78 78
 
79 79
 	allNetworks := []string{objectName("foo", "network1"), objectName("bar", "network1")}
80
-	allNetworksIDs := buildObjectIDs(allNetworks)
80
+	allNetworkIDs := buildObjectIDs(allNetworks)
81 81
 
82 82
 	allSecrets := []string{objectName("foo", "secret1"), objectName("bar", "secret1")}
83
-	allSecretsIDs := buildObjectIDs(allSecrets)
83
+	allSecretIDs := buildObjectIDs(allSecrets)
84 84
 
85 85
 	removedServices := []string{}
86 86
 	cli := &fakeClient{
... ...
@@ -100,8 +100,8 @@ func TestContinueAfterError(t *testing.T) {
100 100
 	cmd := newRemoveCommand(test.NewFakeCli(cli, &bytes.Buffer{}))
101 101
 	cmd.SetArgs([]string{"foo", "bar"})
102 102
 
103
-	assert.Error(t, cmd.Execute(), "Failed to remove some resources from stack: foo")
104
-	assert.DeepEqual(t, removedServices, allServicesIDs)
105
-	assert.DeepEqual(t, cli.removedNetworks, allNetworksIDs)
106
-	assert.DeepEqual(t, cli.removedSecrets, allSecretsIDs)
103
+	assert.EqualError(t, cmd.Execute(), "Failed to remove some resources from stack: foo")
104
+	assert.Equal(t, allServiceIDs, removedServices)
105
+	assert.Equal(t, allNetworkIDs, cli.removedNetworks)
106
+	assert.Equal(t, allSecretIDs, cli.removedSecrets)
107 107
 }
... ...
@@ -9,9 +9,10 @@ import (
9 9
 	"github.com/docker/docker/api/types"
10 10
 	"github.com/docker/docker/api/types/swarm"
11 11
 	"github.com/docker/docker/cli/internal/test"
12
-	"github.com/docker/docker/pkg/testutil/assert"
12
+	"github.com/docker/docker/pkg/testutil"
13 13
 	"github.com/docker/docker/pkg/testutil/golden"
14 14
 	"github.com/pkg/errors"
15
+	"github.com/stretchr/testify/assert"
15 16
 )
16 17
 
17 18
 func TestSwarmInitErrorOnAPIFailure(t *testing.T) {
... ...
@@ -76,7 +77,7 @@ func TestSwarmInitErrorOnAPIFailure(t *testing.T) {
76 76
 			cmd.Flags().Set(key, value)
77 77
 		}
78 78
 		cmd.SetOutput(ioutil.Discard)
79
-		assert.Error(t, cmd.Execute(), tc.expectedError)
79
+		assert.EqualError(t, cmd.Execute(), tc.expectedError)
80 80
 	}
81 81
 }
82 82
 
... ...
@@ -122,9 +123,9 @@ func TestSwarmInit(t *testing.T) {
122 122
 		for key, value := range tc.flags {
123 123
 			cmd.Flags().Set(key, value)
124 124
 		}
125
-		assert.NilError(t, cmd.Execute())
125
+		assert.NoError(t, cmd.Execute())
126 126
 		actual := buf.String()
127 127
 		expected := golden.Get(t, []byte(actual), fmt.Sprintf("init-%s.golden", tc.name))
128
-		assert.EqualNormalizedString(t, assert.RemoveSpace, actual, string(expected))
128
+		testutil.EqualNormalizedString(t, testutil.RemoveSpace, actual, string(expected))
129 129
 	}
130 130
 }
... ...
@@ -9,8 +9,9 @@ import (
9 9
 	"github.com/docker/docker/api/types"
10 10
 	"github.com/docker/docker/api/types/swarm"
11 11
 	"github.com/docker/docker/cli/internal/test"
12
-	"github.com/docker/docker/pkg/testutil/assert"
12
+	"github.com/docker/docker/pkg/testutil"
13 13
 	"github.com/pkg/errors"
14
+	"github.com/stretchr/testify/assert"
14 15
 )
15 16
 
16 17
 func TestSwarmJoinErrors(t *testing.T) {
... ...
@@ -56,7 +57,7 @@ func TestSwarmJoinErrors(t *testing.T) {
56 56
 			}, buf))
57 57
 		cmd.SetArgs(tc.args)
58 58
 		cmd.SetOutput(ioutil.Discard)
59
-		assert.Error(t, cmd.Execute(), tc.expectedError)
59
+		testutil.ErrorContains(t, cmd.Execute(), tc.expectedError)
60 60
 	}
61 61
 }
62 62
 
... ...
@@ -96,7 +97,7 @@ func TestSwarmJoin(t *testing.T) {
96 96
 				infoFunc: tc.infoFunc,
97 97
 			}, buf))
98 98
 		cmd.SetArgs([]string{"remote"})
99
-		assert.NilError(t, cmd.Execute())
99
+		assert.NoError(t, cmd.Execute())
100 100
 		assert.Equal(t, strings.TrimSpace(buf.String()), tc.expected)
101 101
 	}
102 102
 }
... ...
@@ -12,8 +12,9 @@ import (
12 12
 	"github.com/pkg/errors"
13 13
 	// Import builders to get the builder function as package function
14 14
 	. "github.com/docker/docker/cli/internal/test/builders"
15
-	"github.com/docker/docker/pkg/testutil/assert"
15
+	"github.com/docker/docker/pkg/testutil"
16 16
 	"github.com/docker/docker/pkg/testutil/golden"
17
+	"github.com/stretchr/testify/assert"
17 18
 )
18 19
 
19 20
 func TestSwarmJoinTokenErrors(t *testing.T) {
... ...
@@ -102,7 +103,7 @@ func TestSwarmJoinTokenErrors(t *testing.T) {
102 102
 			cmd.Flags().Set(key, value)
103 103
 		}
104 104
 		cmd.SetOutput(ioutil.Discard)
105
-		assert.Error(t, cmd.Execute(), tc.expectedError)
105
+		testutil.ErrorContains(t, cmd.Execute(), tc.expectedError)
106 106
 	}
107 107
 }
108 108
 
... ...
@@ -208,9 +209,9 @@ func TestSwarmJoinToken(t *testing.T) {
208 208
 		for key, value := range tc.flags {
209 209
 			cmd.Flags().Set(key, value)
210 210
 		}
211
-		assert.NilError(t, cmd.Execute())
211
+		assert.NoError(t, cmd.Execute())
212 212
 		actual := buf.String()
213 213
 		expected := golden.Get(t, []byte(actual), fmt.Sprintf("jointoken-%s.golden", tc.name))
214
-		assert.EqualNormalizedString(t, assert.RemoveSpace, actual, string(expected))
214
+		testutil.EqualNormalizedString(t, testutil.RemoveSpace, actual, string(expected))
215 215
 	}
216 216
 }
... ...
@@ -7,8 +7,9 @@ import (
7 7
 	"testing"
8 8
 
9 9
 	"github.com/docker/docker/cli/internal/test"
10
-	"github.com/docker/docker/pkg/testutil/assert"
10
+	"github.com/docker/docker/pkg/testutil"
11 11
 	"github.com/pkg/errors"
12
+	"github.com/stretchr/testify/assert"
12 13
 )
13 14
 
14 15
 func TestSwarmLeaveErrors(t *testing.T) {
... ...
@@ -39,7 +40,7 @@ func TestSwarmLeaveErrors(t *testing.T) {
39 39
 			}, buf))
40 40
 		cmd.SetArgs(tc.args)
41 41
 		cmd.SetOutput(ioutil.Discard)
42
-		assert.Error(t, cmd.Execute(), tc.expectedError)
42
+		testutil.ErrorContains(t, cmd.Execute(), tc.expectedError)
43 43
 	}
44 44
 }
45 45
 
... ...
@@ -47,6 +48,6 @@ func TestSwarmLeave(t *testing.T) {
47 47
 	buf := new(bytes.Buffer)
48 48
 	cmd := newLeaveCommand(
49 49
 		test.NewFakeCli(&fakeClient{}, buf))
50
-	assert.NilError(t, cmd.Execute())
51
-	assert.Equal(t, strings.TrimSpace(buf.String()), "Node left the swarm.")
50
+	assert.NoError(t, cmd.Execute())
51
+	assert.Equal(t, "Node left the swarm.", strings.TrimSpace(buf.String()))
52 52
 }
... ...
@@ -3,37 +3,37 @@ package swarm
3 3
 import (
4 4
 	"testing"
5 5
 
6
-	"github.com/docker/docker/pkg/testutil/assert"
6
+	"github.com/stretchr/testify/assert"
7 7
 )
8 8
 
9 9
 func TestNodeAddrOptionSetHostAndPort(t *testing.T) {
10 10
 	opt := NewNodeAddrOption("old:123")
11 11
 	addr := "newhost:5555"
12
-	assert.NilError(t, opt.Set(addr))
13
-	assert.Equal(t, opt.Value(), addr)
12
+	assert.NoError(t, opt.Set(addr))
13
+	assert.Equal(t, addr, opt.Value())
14 14
 }
15 15
 
16 16
 func TestNodeAddrOptionSetHostOnly(t *testing.T) {
17 17
 	opt := NewListenAddrOption()
18
-	assert.NilError(t, opt.Set("newhost"))
19
-	assert.Equal(t, opt.Value(), "newhost:2377")
18
+	assert.NoError(t, opt.Set("newhost"))
19
+	assert.Equal(t, "newhost:2377", opt.Value())
20 20
 }
21 21
 
22 22
 func TestNodeAddrOptionSetHostOnlyIPv6(t *testing.T) {
23 23
 	opt := NewListenAddrOption()
24
-	assert.NilError(t, opt.Set("::1"))
25
-	assert.Equal(t, opt.Value(), "[::1]:2377")
24
+	assert.NoError(t, opt.Set("::1"))
25
+	assert.Equal(t, "[::1]:2377", opt.Value())
26 26
 }
27 27
 
28 28
 func TestNodeAddrOptionSetPortOnly(t *testing.T) {
29 29
 	opt := NewListenAddrOption()
30
-	assert.NilError(t, opt.Set(":4545"))
31
-	assert.Equal(t, opt.Value(), "0.0.0.0:4545")
30
+	assert.NoError(t, opt.Set(":4545"))
31
+	assert.Equal(t, "0.0.0.0:4545", opt.Value())
32 32
 }
33 33
 
34 34
 func TestNodeAddrOptionSetInvalidFormat(t *testing.T) {
35 35
 	opt := NewListenAddrOption()
36
-	assert.Error(t, opt.Set("http://localhost:4545"), "Invalid")
36
+	assert.EqualError(t, opt.Set("http://localhost:4545"), "Invalid proto, expected tcp: http://localhost:4545")
37 37
 }
38 38
 
39 39
 func TestExternalCAOptionErrors(t *testing.T) {
... ...
@@ -64,7 +64,7 @@ func TestExternalCAOptionErrors(t *testing.T) {
64 64
 	}
65 65
 	for _, tc := range testCases {
66 66
 		opt := &ExternalCAOption{}
67
-		assert.Error(t, opt.Set(tc.externalCA), tc.expectedError)
67
+		assert.EqualError(t, opt.Set(tc.externalCA), tc.expectedError)
68 68
 	}
69 69
 }
70 70
 
... ...
@@ -96,15 +96,15 @@ func TestExternalCAOption(t *testing.T) {
96 96
 	}
97 97
 	for _, tc := range testCases {
98 98
 		opt := &ExternalCAOption{}
99
-		assert.NilError(t, opt.Set(tc.externalCA))
100
-		assert.Equal(t, opt.String(), tc.expected)
99
+		assert.NoError(t, opt.Set(tc.externalCA))
100
+		assert.Equal(t, tc.expected, opt.String())
101 101
 	}
102 102
 }
103 103
 
104 104
 func TestExternalCAOptionMultiple(t *testing.T) {
105 105
 	opt := &ExternalCAOption{}
106
-	assert.NilError(t, opt.Set("protocol=cfssl,url=https://example.com"))
107
-	assert.NilError(t, opt.Set("protocol=CFSSL,url=anything"))
108
-	assert.Equal(t, len(opt.Value()), 2)
109
-	assert.Equal(t, opt.String(), "cfssl: https://example.com, cfssl: anything")
106
+	assert.NoError(t, opt.Set("protocol=cfssl,url=https://example.com"))
107
+	assert.NoError(t, opt.Set("protocol=CFSSL,url=anything"))
108
+	assert.Len(t, opt.Value(), 2)
109
+	assert.Equal(t, "cfssl: https://example.com, cfssl: anything", opt.String())
110 110
 }
... ...
@@ -12,8 +12,9 @@ import (
12 12
 	"github.com/pkg/errors"
13 13
 	// Import builders to get the builder function as package function
14 14
 	. "github.com/docker/docker/cli/internal/test/builders"
15
-	"github.com/docker/docker/pkg/testutil/assert"
15
+	"github.com/docker/docker/pkg/testutil"
16 16
 	"github.com/docker/docker/pkg/testutil/golden"
17
+	"github.com/stretchr/testify/assert"
17 18
 )
18 19
 
19 20
 func TestSwarmUnlockKeyErrors(t *testing.T) {
... ...
@@ -94,7 +95,7 @@ func TestSwarmUnlockKeyErrors(t *testing.T) {
94 94
 			cmd.Flags().Set(key, value)
95 95
 		}
96 96
 		cmd.SetOutput(ioutil.Discard)
97
-		assert.Error(t, cmd.Execute(), tc.expectedError)
97
+		testutil.ErrorContains(t, cmd.Execute(), tc.expectedError)
98 98
 	}
99 99
 }
100 100
 
... ...
@@ -168,9 +169,9 @@ func TestSwarmUnlockKey(t *testing.T) {
168 168
 		for key, value := range tc.flags {
169 169
 			cmd.Flags().Set(key, value)
170 170
 		}
171
-		assert.NilError(t, cmd.Execute())
171
+		assert.NoError(t, cmd.Execute())
172 172
 		actual := buf.String()
173 173
 		expected := golden.Get(t, []byte(actual), fmt.Sprintf("unlockkeys-%s.golden", tc.name))
174
-		assert.EqualNormalizedString(t, assert.RemoveSpace, actual, string(expected))
174
+		testutil.EqualNormalizedString(t, testutil.RemoveSpace, actual, string(expected))
175 175
 	}
176 176
 }
... ...
@@ -9,8 +9,9 @@ import (
9 9
 	"github.com/docker/docker/api/types"
10 10
 	"github.com/docker/docker/api/types/swarm"
11 11
 	"github.com/docker/docker/cli/internal/test"
12
-	"github.com/docker/docker/pkg/testutil/assert"
12
+	"github.com/docker/docker/pkg/testutil"
13 13
 	"github.com/pkg/errors"
14
+	"github.com/stretchr/testify/assert"
14 15
 )
15 16
 
16 17
 func TestSwarmUnlockErrors(t *testing.T) {
... ...
@@ -73,7 +74,7 @@ func TestSwarmUnlockErrors(t *testing.T) {
73 73
 			}, buf))
74 74
 		cmd.SetArgs(tc.args)
75 75
 		cmd.SetOutput(ioutil.Discard)
76
-		assert.Error(t, cmd.Execute(), tc.expectedError)
76
+		testutil.ErrorContains(t, cmd.Execute(), tc.expectedError)
77 77
 	}
78 78
 }
79 79
 
... ...
@@ -97,5 +98,5 @@ func TestSwarmUnlock(t *testing.T) {
97 97
 	}, buf)
98 98
 	dockerCli.SetIn(ioutil.NopCloser(strings.NewReader(input)))
99 99
 	cmd := newUnlockCommand(dockerCli)
100
-	assert.NilError(t, cmd.Execute())
100
+	assert.NoError(t, cmd.Execute())
101 101
 }
... ...
@@ -13,8 +13,9 @@ import (
13 13
 	"github.com/pkg/errors"
14 14
 	// Import builders to get the builder function as package function
15 15
 	. "github.com/docker/docker/cli/internal/test/builders"
16
-	"github.com/docker/docker/pkg/testutil/assert"
16
+	"github.com/docker/docker/pkg/testutil"
17 17
 	"github.com/docker/docker/pkg/testutil/golden"
18
+	"github.com/stretchr/testify/assert"
18 19
 )
19 20
 
20 21
 func TestSwarmUpdateErrors(t *testing.T) {
... ...
@@ -79,7 +80,7 @@ func TestSwarmUpdateErrors(t *testing.T) {
79 79
 			cmd.Flags().Set(key, value)
80 80
 		}
81 81
 		cmd.SetOutput(ioutil.Discard)
82
-		assert.Error(t, cmd.Execute(), tc.expectedError)
82
+		testutil.ErrorContains(t, cmd.Execute(), tc.expectedError)
83 83
 	}
84 84
 }
85 85
 
... ...
@@ -175,9 +176,9 @@ func TestSwarmUpdate(t *testing.T) {
175 175
 			cmd.Flags().Set(key, value)
176 176
 		}
177 177
 		cmd.SetOutput(buf)
178
-		assert.NilError(t, cmd.Execute())
178
+		assert.NoError(t, cmd.Execute())
179 179
 		actual := buf.String()
180 180
 		expected := golden.Get(t, []byte(actual), fmt.Sprintf("update-%s.golden", tc.name))
181
-		assert.EqualNormalizedString(t, assert.RemoveSpace, actual, string(expected))
181
+		testutil.EqualNormalizedString(t, testutil.RemoveSpace, actual, string(expected))
182 182
 	}
183 183
 }
... ...
@@ -9,8 +9,9 @@ import (
9 9
 	"github.com/docker/docker/api/types"
10 10
 	volumetypes "github.com/docker/docker/api/types/volume"
11 11
 	"github.com/docker/docker/cli/internal/test"
12
-	"github.com/docker/docker/pkg/testutil/assert"
12
+	"github.com/docker/docker/pkg/testutil"
13 13
 	"github.com/pkg/errors"
14
+	"github.com/stretchr/testify/assert"
14 15
 )
15 16
 
16 17
 func TestVolumeCreateErrors(t *testing.T) {
... ...
@@ -50,7 +51,7 @@ func TestVolumeCreateErrors(t *testing.T) {
50 50
 			cmd.Flags().Set(key, value)
51 51
 		}
52 52
 		cmd.SetOutput(ioutil.Discard)
53
-		assert.Error(t, cmd.Execute(), tc.expectedError)
53
+		testutil.ErrorContains(t, cmd.Execute(), tc.expectedError)
54 54
 	}
55 55
 }
56 56
 
... ...
@@ -71,15 +72,15 @@ func TestVolumeCreateWithName(t *testing.T) {
71 71
 	// Test by flags
72 72
 	cmd := newCreateCommand(cli)
73 73
 	cmd.Flags().Set("name", name)
74
-	assert.NilError(t, cmd.Execute())
75
-	assert.Equal(t, strings.TrimSpace(buf.String()), name)
74
+	assert.NoError(t, cmd.Execute())
75
+	assert.Equal(t, name, strings.TrimSpace(buf.String()))
76 76
 
77 77
 	// Then by args
78 78
 	buf.Reset()
79 79
 	cmd = newCreateCommand(cli)
80 80
 	cmd.SetArgs([]string{name})
81
-	assert.NilError(t, cmd.Execute())
82
-	assert.Equal(t, strings.TrimSpace(buf.String()), name)
81
+	assert.NoError(t, cmd.Execute())
82
+	assert.Equal(t, name, strings.TrimSpace(buf.String()))
83 83
 }
84 84
 
85 85
 func TestVolumeCreateWithFlags(t *testing.T) {
... ...
@@ -121,8 +122,8 @@ func TestVolumeCreateWithFlags(t *testing.T) {
121 121
 	cmd.Flags().Set("opt", "baz=baz")
122 122
 	cmd.Flags().Set("label", "lbl1=v1")
123 123
 	cmd.Flags().Set("label", "lbl2=v2")
124
-	assert.NilError(t, cmd.Execute())
125
-	assert.Equal(t, strings.TrimSpace(buf.String()), name)
124
+	assert.NoError(t, cmd.Execute())
125
+	assert.Equal(t, name, strings.TrimSpace(buf.String()))
126 126
 }
127 127
 
128 128
 func compareMap(actual map[string]string, expected map[string]string) bool {
... ...
@@ -11,8 +11,9 @@ import (
11 11
 	"github.com/pkg/errors"
12 12
 	// Import builders to get the builder function as package function
13 13
 	. "github.com/docker/docker/cli/internal/test/builders"
14
-	"github.com/docker/docker/pkg/testutil/assert"
14
+	"github.com/docker/docker/pkg/testutil"
15 15
 	"github.com/docker/docker/pkg/testutil/golden"
16
+	"github.com/stretchr/testify/assert"
16 17
 )
17 18
 
18 19
 func TestVolumeInspectErrors(t *testing.T) {
... ...
@@ -64,7 +65,7 @@ func TestVolumeInspectErrors(t *testing.T) {
64 64
 			cmd.Flags().Set(key, value)
65 65
 		}
66 66
 		cmd.SetOutput(ioutil.Discard)
67
-		assert.Error(t, cmd.Execute(), tc.expectedError)
67
+		testutil.ErrorContains(t, cmd.Execute(), tc.expectedError)
68 68
 	}
69 69
 }
70 70
 
... ...
@@ -102,10 +103,10 @@ func TestVolumeInspectWithoutFormat(t *testing.T) {
102 102
 			}, buf),
103 103
 		)
104 104
 		cmd.SetArgs(tc.args)
105
-		assert.NilError(t, cmd.Execute())
105
+		assert.NoError(t, cmd.Execute())
106 106
 		actual := buf.String()
107 107
 		expected := golden.Get(t, []byte(actual), fmt.Sprintf("volume-inspect-without-format.%s.golden", tc.name))
108
-		assert.EqualNormalizedString(t, assert.RemoveSpace, actual, string(expected))
108
+		testutil.EqualNormalizedString(t, testutil.RemoveSpace, actual, string(expected))
109 109
 	}
110 110
 }
111 111
 
... ...
@@ -143,9 +144,9 @@ func TestVolumeInspectWithFormat(t *testing.T) {
143 143
 		)
144 144
 		cmd.SetArgs(tc.args)
145 145
 		cmd.Flags().Set("format", tc.format)
146
-		assert.NilError(t, cmd.Execute())
146
+		assert.NoError(t, cmd.Execute())
147 147
 		actual := buf.String()
148 148
 		expected := golden.Get(t, []byte(actual), fmt.Sprintf("volume-inspect-with-format.%s.golden", tc.name))
149
-		assert.EqualNormalizedString(t, assert.RemoveSpace, actual, string(expected))
149
+		testutil.EqualNormalizedString(t, testutil.RemoveSpace, actual, string(expected))
150 150
 	}
151 151
 }
... ...
@@ -13,8 +13,9 @@ import (
13 13
 	"github.com/pkg/errors"
14 14
 	// Import builders to get the builder function as package function
15 15
 	. "github.com/docker/docker/cli/internal/test/builders"
16
-	"github.com/docker/docker/pkg/testutil/assert"
16
+	"github.com/docker/docker/pkg/testutil"
17 17
 	"github.com/docker/docker/pkg/testutil/golden"
18
+	"github.com/stretchr/testify/assert"
18 19
 )
19 20
 
20 21
 func TestVolumeListErrors(t *testing.T) {
... ...
@@ -47,7 +48,7 @@ func TestVolumeListErrors(t *testing.T) {
47 47
 			cmd.Flags().Set(key, value)
48 48
 		}
49 49
 		cmd.SetOutput(ioutil.Discard)
50
-		assert.Error(t, cmd.Execute(), tc.expectedError)
50
+		testutil.ErrorContains(t, cmd.Execute(), tc.expectedError)
51 51
 	}
52 52
 }
53 53
 
... ...
@@ -68,10 +69,10 @@ func TestVolumeListWithoutFormat(t *testing.T) {
68 68
 	}, buf)
69 69
 	cli.SetConfigfile(&configfile.ConfigFile{})
70 70
 	cmd := newListCommand(cli)
71
-	assert.NilError(t, cmd.Execute())
71
+	assert.NoError(t, cmd.Execute())
72 72
 	actual := buf.String()
73 73
 	expected := golden.Get(t, []byte(actual), "volume-list-without-format.golden")
74
-	assert.EqualNormalizedString(t, assert.RemoveSpace, actual, string(expected))
74
+	testutil.EqualNormalizedString(t, testutil.RemoveSpace, actual, string(expected))
75 75
 }
76 76
 
77 77
 func TestVolumeListWithConfigFormat(t *testing.T) {
... ...
@@ -93,10 +94,10 @@ func TestVolumeListWithConfigFormat(t *testing.T) {
93 93
 		VolumesFormat: "{{ .Name }} {{ .Driver }} {{ .Labels }}",
94 94
 	})
95 95
 	cmd := newListCommand(cli)
96
-	assert.NilError(t, cmd.Execute())
96
+	assert.NoError(t, cmd.Execute())
97 97
 	actual := buf.String()
98 98
 	expected := golden.Get(t, []byte(actual), "volume-list-with-config-format.golden")
99
-	assert.EqualNormalizedString(t, assert.RemoveSpace, actual, string(expected))
99
+	testutil.EqualNormalizedString(t, testutil.RemoveSpace, actual, string(expected))
100 100
 }
101 101
 
102 102
 func TestVolumeListWithFormat(t *testing.T) {
... ...
@@ -117,8 +118,8 @@ func TestVolumeListWithFormat(t *testing.T) {
117 117
 	cli.SetConfigfile(&configfile.ConfigFile{})
118 118
 	cmd := newListCommand(cli)
119 119
 	cmd.Flags().Set("format", "{{ .Name }} {{ .Driver }} {{ .Labels }}")
120
-	assert.NilError(t, cmd.Execute())
120
+	assert.NoError(t, cmd.Execute())
121 121
 	actual := buf.String()
122 122
 	expected := golden.Get(t, []byte(actual), "volume-list-with-format.golden")
123
-	assert.EqualNormalizedString(t, assert.RemoveSpace, actual, string(expected))
123
+	testutil.EqualNormalizedString(t, testutil.RemoveSpace, actual, string(expected))
124 124
 }
... ...
@@ -11,9 +11,10 @@ import (
11 11
 	"github.com/docker/docker/api/types"
12 12
 	"github.com/docker/docker/api/types/filters"
13 13
 	"github.com/docker/docker/cli/internal/test"
14
-	"github.com/docker/docker/pkg/testutil/assert"
14
+	"github.com/docker/docker/pkg/testutil"
15 15
 	"github.com/docker/docker/pkg/testutil/golden"
16 16
 	"github.com/pkg/errors"
17
+	"github.com/stretchr/testify/assert"
17 18
 )
18 19
 
19 20
 func TestVolumePruneErrors(t *testing.T) {
... ...
@@ -48,7 +49,7 @@ func TestVolumePruneErrors(t *testing.T) {
48 48
 			cmd.Flags().Set(key, value)
49 49
 		}
50 50
 		cmd.SetOutput(ioutil.Discard)
51
-		assert.Error(t, cmd.Execute(), tc.expectedError)
51
+		testutil.ErrorContains(t, cmd.Execute(), tc.expectedError)
52 52
 	}
53 53
 }
54 54
 
... ...
@@ -73,10 +74,10 @@ func TestVolumePruneForce(t *testing.T) {
73 73
 			}, buf),
74 74
 		)
75 75
 		cmd.Flags().Set("force", "true")
76
-		assert.NilError(t, cmd.Execute())
76
+		assert.NoError(t, cmd.Execute())
77 77
 		actual := buf.String()
78 78
 		expected := golden.Get(t, []byte(actual), fmt.Sprintf("volume-prune.%s.golden", tc.name))
79
-		assert.EqualNormalizedString(t, assert.RemoveSpace, actual, string(expected))
79
+		testutil.EqualNormalizedString(t, testutil.RemoveSpace, actual, string(expected))
80 80
 	}
81 81
 }
82 82
 func TestVolumePrunePromptYes(t *testing.T) {
... ...
@@ -94,10 +95,10 @@ func TestVolumePrunePromptYes(t *testing.T) {
94 94
 		cmd := NewPruneCommand(
95 95
 			cli,
96 96
 		)
97
-		assert.NilError(t, cmd.Execute())
97
+		assert.NoError(t, cmd.Execute())
98 98
 		actual := buf.String()
99 99
 		expected := golden.Get(t, []byte(actual), "volume-prune-yes.golden")
100
-		assert.EqualNormalizedString(t, assert.RemoveSpace, actual, string(expected))
100
+		testutil.EqualNormalizedString(t, testutil.RemoveSpace, actual, string(expected))
101 101
 	}
102 102
 }
103 103
 
... ...
@@ -116,10 +117,10 @@ func TestVolumePrunePromptNo(t *testing.T) {
116 116
 		cmd := NewPruneCommand(
117 117
 			cli,
118 118
 		)
119
-		assert.NilError(t, cmd.Execute())
119
+		assert.NoError(t, cmd.Execute())
120 120
 		actual := buf.String()
121 121
 		expected := golden.Get(t, []byte(actual), "volume-prune-no.golden")
122
-		assert.EqualNormalizedString(t, assert.RemoveSpace, actual, string(expected))
122
+		testutil.EqualNormalizedString(t, testutil.RemoveSpace, actual, string(expected))
123 123
 	}
124 124
 }
125 125
 
... ...
@@ -6,8 +6,9 @@ import (
6 6
 	"testing"
7 7
 
8 8
 	"github.com/docker/docker/cli/internal/test"
9
-	"github.com/docker/docker/pkg/testutil/assert"
9
+	"github.com/docker/docker/pkg/testutil"
10 10
 	"github.com/pkg/errors"
11
+	"github.com/stretchr/testify/assert"
11 12
 )
12 13
 
13 14
 func TestVolumeRemoveErrors(t *testing.T) {
... ...
@@ -35,7 +36,7 @@ func TestVolumeRemoveErrors(t *testing.T) {
35 35
 			}, buf))
36 36
 		cmd.SetArgs(tc.args)
37 37
 		cmd.SetOutput(ioutil.Discard)
38
-		assert.Error(t, cmd.Execute(), tc.expectedError)
38
+		testutil.ErrorContains(t, cmd.Execute(), tc.expectedError)
39 39
 	}
40 40
 }
41 41
 
... ...
@@ -43,5 +44,5 @@ func TestNodeRemoveMultiple(t *testing.T) {
43 43
 	buf := new(bytes.Buffer)
44 44
 	cmd := newRemoveCommand(test.NewFakeCli(&fakeClient{}, buf))
45 45
 	cmd.SetArgs([]string{"volume1", "volume2"})
46
-	assert.NilError(t, cmd.Execute())
46
+	assert.NoError(t, cmd.Execute())
47 47
 }
... ...
@@ -6,13 +6,14 @@ import (
6 6
 	"github.com/docker/docker/api/types"
7 7
 	"github.com/docker/docker/api/types/network"
8 8
 	composetypes "github.com/docker/docker/cli/compose/types"
9
-	"github.com/docker/docker/pkg/testutil/assert"
10 9
 	"github.com/docker/docker/pkg/testutil/tempfile"
10
+	"github.com/stretchr/testify/assert"
11
+	"github.com/stretchr/testify/require"
11 12
 )
12 13
 
13 14
 func TestNamespaceScope(t *testing.T) {
14 15
 	scoped := Namespace{name: "foo"}.Scope("bar")
15
-	assert.Equal(t, scoped, "foo_bar")
16
+	assert.Equal(t, "foo_bar", scoped)
16 17
 }
17 18
 
18 19
 func TestAddStackLabel(t *testing.T) {
... ...
@@ -24,7 +25,7 @@ func TestAddStackLabel(t *testing.T) {
24 24
 		"something":    "labeled",
25 25
 		LabelNamespace: "foo",
26 26
 	}
27
-	assert.DeepEqual(t, actual, expected)
27
+	assert.Equal(t, expected, actual)
28 28
 }
29 29
 
30 30
 func TestNetworks(t *testing.T) {
... ...
@@ -98,8 +99,8 @@ func TestNetworks(t *testing.T) {
98 98
 	}
99 99
 
100 100
 	networks, externals := Networks(namespace, source, serviceNetworks)
101
-	assert.DeepEqual(t, networks, expected)
102
-	assert.DeepEqual(t, externals, []string{"special"})
101
+	assert.Equal(t, expected, networks)
102
+	assert.Equal(t, []string{"special"}, externals)
103 103
 }
104 104
 
105 105
 func TestSecrets(t *testing.T) {
... ...
@@ -122,13 +123,13 @@ func TestSecrets(t *testing.T) {
122 122
 	}
123 123
 
124 124
 	specs, err := Secrets(namespace, source)
125
-	assert.NilError(t, err)
126
-	assert.Equal(t, len(specs), 1)
125
+	assert.NoError(t, err)
126
+	require.Len(t, specs, 1)
127 127
 	secret := specs[0]
128
-	assert.Equal(t, secret.Name, "foo_one")
129
-	assert.DeepEqual(t, secret.Labels, map[string]string{
128
+	assert.Equal(t, "foo_one", secret.Name)
129
+	assert.Equal(t, map[string]string{
130 130
 		"monster":      "mash",
131 131
 		LabelNamespace: "foo",
132
-	})
133
-	assert.DeepEqual(t, secret.Data, []byte(secretText))
132
+	}, secret.Labels)
133
+	assert.Equal(t, []byte(secretText), secret.Data)
134 134
 }
... ...
@@ -9,18 +9,18 @@ import (
9 9
 	"github.com/docker/docker/api/types/container"
10 10
 	"github.com/docker/docker/api/types/swarm"
11 11
 	composetypes "github.com/docker/docker/cli/compose/types"
12
-	"github.com/docker/docker/pkg/testutil/assert"
12
+	"github.com/stretchr/testify/assert"
13 13
 )
14 14
 
15 15
 func TestConvertRestartPolicyFromNone(t *testing.T) {
16 16
 	policy, err := convertRestartPolicy("no", nil)
17
-	assert.NilError(t, err)
18
-	assert.Equal(t, policy, (*swarm.RestartPolicy)(nil))
17
+	assert.NoError(t, err)
18
+	assert.Equal(t, (*swarm.RestartPolicy)(nil), policy)
19 19
 }
20 20
 
21 21
 func TestConvertRestartPolicyFromUnknown(t *testing.T) {
22 22
 	_, err := convertRestartPolicy("unknown", nil)
23
-	assert.Error(t, err, "unknown restart policy: unknown")
23
+	assert.EqualError(t, err, "unknown restart policy: unknown")
24 24
 }
25 25
 
26 26
 func TestConvertRestartPolicyFromAlways(t *testing.T) {
... ...
@@ -28,8 +28,8 @@ func TestConvertRestartPolicyFromAlways(t *testing.T) {
28 28
 	expected := &swarm.RestartPolicy{
29 29
 		Condition: swarm.RestartPolicyConditionAny,
30 30
 	}
31
-	assert.NilError(t, err)
32
-	assert.DeepEqual(t, policy, expected)
31
+	assert.NoError(t, err)
32
+	assert.Equal(t, expected, policy)
33 33
 }
34 34
 
35 35
 func TestConvertRestartPolicyFromFailure(t *testing.T) {
... ...
@@ -39,8 +39,8 @@ func TestConvertRestartPolicyFromFailure(t *testing.T) {
39 39
 		Condition:   swarm.RestartPolicyConditionOnFailure,
40 40
 		MaxAttempts: &attempts,
41 41
 	}
42
-	assert.NilError(t, err)
43
-	assert.DeepEqual(t, policy, expected)
42
+	assert.NoError(t, err)
43
+	assert.Equal(t, expected, policy)
44 44
 }
45 45
 
46 46
 func strPtr(val string) *string {
... ...
@@ -54,7 +54,7 @@ func TestConvertEnvironment(t *testing.T) {
54 54
 	}
55 55
 	env := convertEnvironment(source)
56 56
 	sort.Strings(env)
57
-	assert.DeepEqual(t, env, []string{"foo=bar", "key=value"})
57
+	assert.Equal(t, []string{"foo=bar", "key=value"}, env)
58 58
 }
59 59
 
60 60
 func TestConvertResourcesFull(t *testing.T) {
... ...
@@ -69,7 +69,7 @@ func TestConvertResourcesFull(t *testing.T) {
69 69
 		},
70 70
 	}
71 71
 	resources, err := convertResources(source)
72
-	assert.NilError(t, err)
72
+	assert.NoError(t, err)
73 73
 
74 74
 	expected := &swarm.ResourceRequirements{
75 75
 		Limits: &swarm.Resources{
... ...
@@ -81,7 +81,7 @@ func TestConvertResourcesFull(t *testing.T) {
81 81
 			MemoryBytes: 200000000,
82 82
 		},
83 83
 	}
84
-	assert.DeepEqual(t, resources, expected)
84
+	assert.Equal(t, expected, resources)
85 85
 }
86 86
 
87 87
 func TestConvertResourcesOnlyMemory(t *testing.T) {
... ...
@@ -94,7 +94,7 @@ func TestConvertResourcesOnlyMemory(t *testing.T) {
94 94
 		},
95 95
 	}
96 96
 	resources, err := convertResources(source)
97
-	assert.NilError(t, err)
97
+	assert.NoError(t, err)
98 98
 
99 99
 	expected := &swarm.ResourceRequirements{
100 100
 		Limits: &swarm.Resources{
... ...
@@ -104,7 +104,7 @@ func TestConvertResourcesOnlyMemory(t *testing.T) {
104 104
 			MemoryBytes: 200000000,
105 105
 		},
106 106
 	}
107
-	assert.DeepEqual(t, resources, expected)
107
+	assert.Equal(t, expected, resources)
108 108
 }
109 109
 
110 110
 func TestConvertHealthcheck(t *testing.T) {
... ...
@@ -123,8 +123,8 @@ func TestConvertHealthcheck(t *testing.T) {
123 123
 	}
124 124
 
125 125
 	healthcheck, err := convertHealthcheck(source)
126
-	assert.NilError(t, err)
127
-	assert.DeepEqual(t, healthcheck, expected)
126
+	assert.NoError(t, err)
127
+	assert.Equal(t, expected, healthcheck)
128 128
 }
129 129
 
130 130
 func TestConvertHealthcheckDisable(t *testing.T) {
... ...
@@ -134,8 +134,8 @@ func TestConvertHealthcheckDisable(t *testing.T) {
134 134
 	}
135 135
 
136 136
 	healthcheck, err := convertHealthcheck(source)
137
-	assert.NilError(t, err)
138
-	assert.DeepEqual(t, healthcheck, expected)
137
+	assert.NoError(t, err)
138
+	assert.Equal(t, expected, healthcheck)
139 139
 }
140 140
 
141 141
 func TestConvertHealthcheckDisableWithTest(t *testing.T) {
... ...
@@ -144,7 +144,7 @@ func TestConvertHealthcheckDisableWithTest(t *testing.T) {
144 144
 		Test:    []string{"EXEC", "touch"},
145 145
 	}
146 146
 	_, err := convertHealthcheck(source)
147
-	assert.Error(t, err, "test and disable can't be set")
147
+	assert.EqualError(t, err, "test and disable can't be set at the same time")
148 148
 }
149 149
 
150 150
 func TestConvertEndpointSpec(t *testing.T) {
... ...
@@ -178,8 +178,8 @@ func TestConvertEndpointSpec(t *testing.T) {
178 178
 		},
179 179
 	}
180 180
 
181
-	assert.NilError(t, err)
182
-	assert.DeepEqual(t, *endpoint, expected)
181
+	assert.NoError(t, err)
182
+	assert.Equal(t, expected, *endpoint)
183 183
 }
184 184
 
185 185
 func TestConvertServiceNetworksOnlyDefault(t *testing.T) {
... ...
@@ -195,8 +195,8 @@ func TestConvertServiceNetworksOnlyDefault(t *testing.T) {
195 195
 		},
196 196
 	}
197 197
 
198
-	assert.NilError(t, err)
199
-	assert.DeepEqual(t, configs, expected)
198
+	assert.NoError(t, err)
199
+	assert.Equal(t, expected, configs)
200 200
 }
201 201
 
202 202
 func TestConvertServiceNetworks(t *testing.T) {
... ...
@@ -235,8 +235,8 @@ func TestConvertServiceNetworks(t *testing.T) {
235 235
 	sortedConfigs := byTargetSort(configs)
236 236
 	sort.Sort(&sortedConfigs)
237 237
 
238
-	assert.NilError(t, err)
239
-	assert.DeepEqual(t, []swarm.NetworkAttachmentConfig(sortedConfigs), expected)
238
+	assert.NoError(t, err)
239
+	assert.Equal(t, expected, []swarm.NetworkAttachmentConfig(sortedConfigs))
240 240
 }
241 241
 
242 242
 func TestConvertServiceNetworksCustomDefault(t *testing.T) {
... ...
@@ -260,8 +260,8 @@ func TestConvertServiceNetworksCustomDefault(t *testing.T) {
260 260
 		},
261 261
 	}
262 262
 
263
-	assert.NilError(t, err)
264
-	assert.DeepEqual(t, []swarm.NetworkAttachmentConfig(configs), expected)
263
+	assert.NoError(t, err)
264
+	assert.Equal(t, expected, []swarm.NetworkAttachmentConfig(configs))
265 265
 }
266 266
 
267 267
 type byTargetSort []swarm.NetworkAttachmentConfig
... ...
@@ -281,8 +281,8 @@ func (s byTargetSort) Swap(i, j int) {
281 281
 func TestConvertDNSConfigEmpty(t *testing.T) {
282 282
 	dnsConfig, err := convertDNSConfig(nil, nil)
283 283
 
284
-	assert.NilError(t, err)
285
-	assert.Equal(t, dnsConfig, (*swarm.DNSConfig)(nil))
284
+	assert.NoError(t, err)
285
+	assert.Equal(t, (*swarm.DNSConfig)(nil), dnsConfig)
286 286
 }
287 287
 
288 288
 var (
... ...
@@ -292,27 +292,27 @@ var (
292 292
 
293 293
 func TestConvertDNSConfigAll(t *testing.T) {
294 294
 	dnsConfig, err := convertDNSConfig(nameservers, search)
295
-	assert.NilError(t, err)
296
-	assert.DeepEqual(t, dnsConfig, &swarm.DNSConfig{
295
+	assert.NoError(t, err)
296
+	assert.Equal(t, &swarm.DNSConfig{
297 297
 		Nameservers: nameservers,
298 298
 		Search:      search,
299
-	})
299
+	}, dnsConfig)
300 300
 }
301 301
 
302 302
 func TestConvertDNSConfigNameservers(t *testing.T) {
303 303
 	dnsConfig, err := convertDNSConfig(nameservers, nil)
304
-	assert.NilError(t, err)
305
-	assert.DeepEqual(t, dnsConfig, &swarm.DNSConfig{
304
+	assert.NoError(t, err)
305
+	assert.Equal(t, &swarm.DNSConfig{
306 306
 		Nameservers: nameservers,
307 307
 		Search:      nil,
308
-	})
308
+	}, dnsConfig)
309 309
 }
310 310
 
311 311
 func TestConvertDNSConfigSearch(t *testing.T) {
312 312
 	dnsConfig, err := convertDNSConfig(nil, search)
313
-	assert.NilError(t, err)
314
-	assert.DeepEqual(t, dnsConfig, &swarm.DNSConfig{
313
+	assert.NoError(t, err)
314
+	assert.Equal(t, &swarm.DNSConfig{
315 315
 		Nameservers: nil,
316 316
 		Search:      search,
317
-	})
317
+	}, dnsConfig)
318 318
 }
... ...
@@ -5,7 +5,7 @@ import (
5 5
 
6 6
 	"github.com/docker/docker/api/types/mount"
7 7
 	composetypes "github.com/docker/docker/cli/compose/types"
8
-	"github.com/docker/docker/pkg/testutil/assert"
8
+	"github.com/stretchr/testify/assert"
9 9
 )
10 10
 
11 11
 func TestConvertVolumeToMountAnonymousVolume(t *testing.T) {
... ...
@@ -18,8 +18,8 @@ func TestConvertVolumeToMountAnonymousVolume(t *testing.T) {
18 18
 		Target: "/foo/bar",
19 19
 	}
20 20
 	mount, err := convertVolumeToMount(config, volumes{}, NewNamespace("foo"))
21
-	assert.NilError(t, err)
22
-	assert.DeepEqual(t, mount, expected)
21
+	assert.NoError(t, err)
22
+	assert.Equal(t, expected, mount)
23 23
 }
24 24
 
25 25
 func TestConvertVolumeToMountConflictingOptionsBind(t *testing.T) {
... ...
@@ -34,7 +34,7 @@ func TestConvertVolumeToMountConflictingOptionsBind(t *testing.T) {
34 34
 		},
35 35
 	}
36 36
 	_, err := convertVolumeToMount(config, volumes{}, namespace)
37
-	assert.Error(t, err, "bind options are incompatible")
37
+	assert.EqualError(t, err, "bind options are incompatible with type volume")
38 38
 }
39 39
 
40 40
 func TestConvertVolumeToMountConflictingOptionsVolume(t *testing.T) {
... ...
@@ -49,7 +49,7 @@ func TestConvertVolumeToMountConflictingOptionsVolume(t *testing.T) {
49 49
 		},
50 50
 	}
51 51
 	_, err := convertVolumeToMount(config, volumes{}, namespace)
52
-	assert.Error(t, err, "volume options are incompatible")
52
+	assert.EqualError(t, err, "volume options are incompatible with type bind")
53 53
 }
54 54
 
55 55
 func TestConvertVolumeToMountNamedVolume(t *testing.T) {
... ...
@@ -94,8 +94,8 @@ func TestConvertVolumeToMountNamedVolume(t *testing.T) {
94 94
 		},
95 95
 	}
96 96
 	mount, err := convertVolumeToMount(config, stackVolumes, namespace)
97
-	assert.NilError(t, err)
98
-	assert.DeepEqual(t, mount, expected)
97
+	assert.NoError(t, err)
98
+	assert.Equal(t, expected, mount)
99 99
 }
100 100
 
101 101
 func TestConvertVolumeToMountNamedVolumeExternal(t *testing.T) {
... ...
@@ -122,8 +122,8 @@ func TestConvertVolumeToMountNamedVolumeExternal(t *testing.T) {
122 122
 		Target: "/foo",
123 123
 	}
124 124
 	mount, err := convertVolumeToMount(config, stackVolumes, namespace)
125
-	assert.NilError(t, err)
126
-	assert.DeepEqual(t, mount, expected)
125
+	assert.NoError(t, err)
126
+	assert.Equal(t, expected, mount)
127 127
 }
128 128
 
129 129
 func TestConvertVolumeToMountNamedVolumeExternalNoCopy(t *testing.T) {
... ...
@@ -153,8 +153,8 @@ func TestConvertVolumeToMountNamedVolumeExternalNoCopy(t *testing.T) {
153 153
 		},
154 154
 	}
155 155
 	mount, err := convertVolumeToMount(config, stackVolumes, namespace)
156
-	assert.NilError(t, err)
157
-	assert.DeepEqual(t, mount, expected)
156
+	assert.NoError(t, err)
157
+	assert.Equal(t, expected, mount)
158 158
 }
159 159
 
160 160
 func TestConvertVolumeToMountBind(t *testing.T) {
... ...
@@ -175,8 +175,8 @@ func TestConvertVolumeToMountBind(t *testing.T) {
175 175
 		Bind:     &composetypes.ServiceVolumeBind{Propagation: "shared"},
176 176
 	}
177 177
 	mount, err := convertVolumeToMount(config, stackVolumes, namespace)
178
-	assert.NilError(t, err)
179
-	assert.DeepEqual(t, mount, expected)
178
+	assert.NoError(t, err)
179
+	assert.Equal(t, expected, mount)
180 180
 }
181 181
 
182 182
 func TestConvertVolumeToMountVolumeDoesNotExist(t *testing.T) {
... ...
@@ -188,5 +188,5 @@ func TestConvertVolumeToMountVolumeDoesNotExist(t *testing.T) {
188 188
 		ReadOnly: true,
189 189
 	}
190 190
 	_, err := convertVolumeToMount(config, volumes{}, namespace)
191
-	assert.Error(t, err, "undefined volume \"unknown\"")
191
+	assert.EqualError(t, err, "undefined volume \"unknown\"")
192 192
 }
... ...
@@ -4,15 +4,16 @@ import (
4 4
 	"testing"
5 5
 
6 6
 	"github.com/docker/docker/cli/compose/types"
7
-	"github.com/docker/docker/pkg/testutil/assert"
7
+	"github.com/docker/docker/pkg/testutil"
8
+	"github.com/stretchr/testify/assert"
8 9
 )
9 10
 
10 11
 func TestParseVolumeAnonymousVolume(t *testing.T) {
11 12
 	for _, path := range []string{"/path", "/path/foo"} {
12 13
 		volume, err := parseVolume(path)
13 14
 		expected := types.ServiceVolumeConfig{Type: "volume", Target: path}
14
-		assert.NilError(t, err)
15
-		assert.DeepEqual(t, volume, expected)
15
+		assert.NoError(t, err)
16
+		assert.Equal(t, expected, volume)
16 17
 	}
17 18
 }
18 19
 
... ...
@@ -20,29 +21,29 @@ func TestParseVolumeAnonymousVolumeWindows(t *testing.T) {
20 20
 	for _, path := range []string{"C:\\path", "Z:\\path\\foo"} {
21 21
 		volume, err := parseVolume(path)
22 22
 		expected := types.ServiceVolumeConfig{Type: "volume", Target: path}
23
-		assert.NilError(t, err)
24
-		assert.DeepEqual(t, volume, expected)
23
+		assert.NoError(t, err)
24
+		assert.Equal(t, expected, volume)
25 25
 	}
26 26
 }
27 27
 
28 28
 func TestParseVolumeTooManyColons(t *testing.T) {
29 29
 	_, err := parseVolume("/foo:/foo:ro:foo")
30
-	assert.Error(t, err, "too many colons")
30
+	assert.EqualError(t, err, "invalid spec: /foo:/foo:ro:foo: too many colons")
31 31
 }
32 32
 
33 33
 func TestParseVolumeShortVolumes(t *testing.T) {
34 34
 	for _, path := range []string{".", "/a"} {
35 35
 		volume, err := parseVolume(path)
36 36
 		expected := types.ServiceVolumeConfig{Type: "volume", Target: path}
37
-		assert.NilError(t, err)
38
-		assert.DeepEqual(t, volume, expected)
37
+		assert.NoError(t, err)
38
+		assert.Equal(t, expected, volume)
39 39
 	}
40 40
 }
41 41
 
42 42
 func TestParseVolumeMissingSource(t *testing.T) {
43 43
 	for _, spec := range []string{":foo", "/foo::ro"} {
44 44
 		_, err := parseVolume(spec)
45
-		assert.Error(t, err, "empty section between colons")
45
+		testutil.ErrorContains(t, err, "empty section between colons")
46 46
 	}
47 47
 }
48 48
 
... ...
@@ -54,8 +55,8 @@ func TestParseVolumeBindMount(t *testing.T) {
54 54
 			Source: path,
55 55
 			Target: "/target",
56 56
 		}
57
-		assert.NilError(t, err)
58
-		assert.DeepEqual(t, volume, expected)
57
+		assert.NoError(t, err)
58
+		assert.Equal(t, expected, volume)
59 59
 	}
60 60
 }
61 61
 
... ...
@@ -72,8 +73,8 @@ func TestParseVolumeRelativeBindMountWindows(t *testing.T) {
72 72
 			Source: path,
73 73
 			Target: "d:\\target",
74 74
 		}
75
-		assert.NilError(t, err)
76
-		assert.DeepEqual(t, volume, expected)
75
+		assert.NoError(t, err)
76
+		assert.Equal(t, expected, volume)
77 77
 	}
78 78
 }
79 79
 
... ...
@@ -85,8 +86,8 @@ func TestParseVolumeWithBindOptions(t *testing.T) {
85 85
 		Target: "/target",
86 86
 		Bind:   &types.ServiceVolumeBind{Propagation: "slave"},
87 87
 	}
88
-	assert.NilError(t, err)
89
-	assert.DeepEqual(t, volume, expected)
88
+	assert.NoError(t, err)
89
+	assert.Equal(t, expected, volume)
90 90
 }
91 91
 
92 92
 func TestParseVolumeWithBindOptionsWindows(t *testing.T) {
... ...
@@ -98,13 +99,13 @@ func TestParseVolumeWithBindOptionsWindows(t *testing.T) {
98 98
 		ReadOnly: true,
99 99
 		Bind:     &types.ServiceVolumeBind{Propagation: "rprivate"},
100 100
 	}
101
-	assert.NilError(t, err)
102
-	assert.DeepEqual(t, volume, expected)
101
+	assert.NoError(t, err)
102
+	assert.Equal(t, expected, volume)
103 103
 }
104 104
 
105 105
 func TestParseVolumeWithInvalidVolumeOptions(t *testing.T) {
106 106
 	_, err := parseVolume("name:/target:bogus")
107
-	assert.Error(t, err, "invalid spec: name:/target:bogus: unknown option: bogus")
107
+	assert.EqualError(t, err, "invalid spec: name:/target:bogus: unknown option: bogus")
108 108
 }
109 109
 
110 110
 func TestParseVolumeWithVolumeOptions(t *testing.T) {
... ...
@@ -115,8 +116,8 @@ func TestParseVolumeWithVolumeOptions(t *testing.T) {
115 115
 		Target: "/target",
116 116
 		Volume: &types.ServiceVolumeVolume{NoCopy: true},
117 117
 	}
118
-	assert.NilError(t, err)
119
-	assert.DeepEqual(t, volume, expected)
118
+	assert.NoError(t, err)
119
+	assert.Equal(t, expected, volume)
120 120
 }
121 121
 
122 122
 func TestParseVolumeWithReadOnly(t *testing.T) {
... ...
@@ -128,8 +129,8 @@ func TestParseVolumeWithReadOnly(t *testing.T) {
128 128
 			Target:   "/target",
129 129
 			ReadOnly: true,
130 130
 		}
131
-		assert.NilError(t, err)
132
-		assert.DeepEqual(t, volume, expected)
131
+		assert.NoError(t, err)
132
+		assert.Equal(t, expected, volume)
133 133
 	}
134 134
 }
135 135
 
... ...
@@ -142,7 +143,7 @@ func TestParseVolumeWithRW(t *testing.T) {
142 142
 			Target:   "/target",
143 143
 			ReadOnly: false,
144 144
 		}
145
-		assert.NilError(t, err)
146
-		assert.DeepEqual(t, volume, expected)
145
+		assert.NoError(t, err)
146
+		assert.Equal(t, expected, volume)
147 147
 	}
148 148
 }
... ...
@@ -18,7 +18,7 @@ func defaultMapping(name string) (string, bool) {
18 18
 
19 19
 func TestEscaped(t *testing.T) {
20 20
 	result, err := Substitute("$${foo}", defaultMapping)
21
-	assert.NoError(t, err)
21
+	assert.Nil(t, err)
22 22
 	assert.Equal(t, "${foo}", result)
23 23
 }
24 24
 
... ...
@@ -43,7 +43,7 @@ func TestInvalid(t *testing.T) {
43 43
 func TestNoValueNoDefault(t *testing.T) {
44 44
 	for _, template := range []string{"This ${missing} var", "This ${BAR} var"} {
45 45
 		result, err := Substitute(template, defaultMapping)
46
-		assert.NoError(t, err)
46
+		assert.Nil(t, err)
47 47
 		assert.Equal(t, "This  var", result)
48 48
 	}
49 49
 }
... ...
@@ -51,7 +51,7 @@ func TestNoValueNoDefault(t *testing.T) {
51 51
 func TestValueNoDefault(t *testing.T) {
52 52
 	for _, template := range []string{"This $FOO var", "This ${FOO} var"} {
53 53
 		result, err := Substitute(template, defaultMapping)
54
-		assert.NoError(t, err)
54
+		assert.Nil(t, err)
55 55
 		assert.Equal(t, "This first var", result)
56 56
 	}
57 57
 }
... ...
@@ -59,25 +59,25 @@ func TestValueNoDefault(t *testing.T) {
59 59
 func TestNoValueWithDefault(t *testing.T) {
60 60
 	for _, template := range []string{"ok ${missing:-def}", "ok ${missing-def}"} {
61 61
 		result, err := Substitute(template, defaultMapping)
62
-		assert.NoError(t, err)
62
+		assert.Nil(t, err)
63 63
 		assert.Equal(t, "ok def", result)
64 64
 	}
65 65
 }
66 66
 
67 67
 func TestEmptyValueWithSoftDefault(t *testing.T) {
68 68
 	result, err := Substitute("ok ${BAR:-def}", defaultMapping)
69
-	assert.NoError(t, err)
69
+	assert.Nil(t, err)
70 70
 	assert.Equal(t, "ok def", result)
71 71
 }
72 72
 
73 73
 func TestEmptyValueWithHardDefault(t *testing.T) {
74 74
 	result, err := Substitute("ok ${BAR-def}", defaultMapping)
75
-	assert.NoError(t, err)
75
+	assert.Nil(t, err)
76 76
 	assert.Equal(t, "ok ", result)
77 77
 }
78 78
 
79 79
 func TestNonAlphanumericDefault(t *testing.T) {
80 80
 	result, err := Substitute("ok ${BAR:-/non:-alphanumeric}", defaultMapping)
81
-	assert.NoError(t, err)
81
+	assert.Nil(t, err)
82 82
 	assert.Equal(t, "ok /non:-alphanumeric", result)
83 83
 }
... ...
@@ -5,8 +5,8 @@ import (
5 5
 	"testing"
6 6
 
7 7
 	cliconfig "github.com/docker/docker/cli/config"
8
-	"github.com/docker/docker/pkg/testutil/assert"
9 8
 	"github.com/spf13/pflag"
9
+	"github.com/stretchr/testify/assert"
10 10
 )
11 11
 
12 12
 func TestCommonOptionsInstallFlags(t *testing.T) {
... ...
@@ -19,9 +19,9 @@ func TestCommonOptionsInstallFlags(t *testing.T) {
19 19
 		"--tlscert=\"/foo/cert\"",
20 20
 		"--tlskey=\"/foo/key\"",
21 21
 	})
22
-	assert.NilError(t, err)
23
-	assert.Equal(t, opts.TLSOptions.CAFile, "/foo/cafile")
24
-	assert.Equal(t, opts.TLSOptions.CertFile, "/foo/cert")
22
+	assert.NoError(t, err)
23
+	assert.Equal(t, "/foo/cafile", opts.TLSOptions.CAFile)
24
+	assert.Equal(t, "/foo/cert", opts.TLSOptions.CertFile)
25 25
 	assert.Equal(t, opts.TLSOptions.KeyFile, "/foo/key")
26 26
 }
27 27
 
... ...
@@ -35,8 +35,8 @@ func TestCommonOptionsInstallFlagsWithDefaults(t *testing.T) {
35 35
 	opts.InstallFlags(flags)
36 36
 
37 37
 	err := flags.Parse([]string{})
38
-	assert.NilError(t, err)
39
-	assert.Equal(t, opts.TLSOptions.CAFile, defaultPath("ca.pem"))
40
-	assert.Equal(t, opts.TLSOptions.CertFile, defaultPath("cert.pem"))
41
-	assert.Equal(t, opts.TLSOptions.KeyFile, defaultPath("key.pem"))
38
+	assert.NoError(t, err)
39
+	assert.Equal(t, defaultPath("ca.pem"), opts.TLSOptions.CAFile)
40
+	assert.Equal(t, defaultPath("cert.pem"), opts.TLSOptions.CertFile)
41
+	assert.Equal(t, defaultPath("key.pem"), opts.TLSOptions.KeyFile)
42 42
 }
... ...
@@ -11,7 +11,7 @@ import (
11 11
 
12 12
 	"github.com/docker/docker/api/types"
13 13
 	"github.com/docker/docker/api/types/filters"
14
-	"github.com/docker/docker/pkg/testutil/assert"
14
+	"github.com/stretchr/testify/assert"
15 15
 	"golang.org/x/net/context"
16 16
 )
17 17
 
... ...
@@ -24,7 +24,7 @@ func TestContainersPruneError(t *testing.T) {
24 24
 	filters := filters.NewArgs()
25 25
 
26 26
 	_, err := client.ContainersPrune(context.Background(), filters)
27
-	assert.Error(t, err, "Error response from daemon: Server error")
27
+	assert.EqualError(t, err, "Error response from daemon: Server error")
28 28
 }
29 29
 
30 30
 func TestContainersPrune(t *testing.T) {
... ...
@@ -99,7 +99,7 @@ func TestContainersPrune(t *testing.T) {
99 99
 				query := req.URL.Query()
100 100
 				for key, expected := range listCase.expectedQueryParams {
101 101
 					actual := query.Get(key)
102
-					assert.Equal(t, actual, expected)
102
+					assert.Equal(t, expected, actual)
103 103
 				}
104 104
 				content, err := json.Marshal(types.ContainersPruneReport{
105 105
 					ContainersDeleted: []string{"container_id1", "container_id2"},
... ...
@@ -117,8 +117,8 @@ func TestContainersPrune(t *testing.T) {
117 117
 		}
118 118
 
119 119
 		report, err := client.ContainersPrune(context.Background(), listCase.filters)
120
-		assert.NilError(t, err)
121
-		assert.Equal(t, len(report.ContainersDeleted), 2)
122
-		assert.Equal(t, report.SpaceReclaimed, uint64(9999))
120
+		assert.NoError(t, err)
121
+		assert.Len(t, report.ContainersDeleted, 2)
122
+		assert.Equal(t, uint64(9999), report.SpaceReclaimed)
123 123
 	}
124 124
 }
... ...
@@ -11,7 +11,7 @@ import (
11 11
 
12 12
 	"github.com/docker/docker/api/types"
13 13
 	"github.com/docker/docker/api/types/filters"
14
-	"github.com/docker/docker/pkg/testutil/assert"
14
+	"github.com/stretchr/testify/assert"
15 15
 	"golang.org/x/net/context"
16 16
 )
17 17
 
... ...
@@ -24,7 +24,7 @@ func TestImagesPruneError(t *testing.T) {
24 24
 	filters := filters.NewArgs()
25 25
 
26 26
 	_, err := client.ImagesPrune(context.Background(), filters)
27
-	assert.Error(t, err, "Error response from daemon: Server error")
27
+	assert.EqualError(t, err, "Error response from daemon: Server error")
28 28
 }
29 29
 
30 30
 func TestImagesPrune(t *testing.T) {
... ...
@@ -87,7 +87,7 @@ func TestImagesPrune(t *testing.T) {
87 87
 				query := req.URL.Query()
88 88
 				for key, expected := range listCase.expectedQueryParams {
89 89
 					actual := query.Get(key)
90
-					assert.Equal(t, actual, expected)
90
+					assert.Equal(t, expected, actual)
91 91
 				}
92 92
 				content, err := json.Marshal(types.ImagesPruneReport{
93 93
 					ImagesDeleted: []types.ImageDeleteResponseItem{
... ...
@@ -112,8 +112,8 @@ func TestImagesPrune(t *testing.T) {
112 112
 		}
113 113
 
114 114
 		report, err := client.ImagesPrune(context.Background(), listCase.filters)
115
-		assert.NilError(t, err)
116
-		assert.Equal(t, len(report.ImagesDeleted), 2)
117
-		assert.Equal(t, report.SpaceReclaimed, uint64(9999))
115
+		assert.NoError(t, err)
116
+		assert.Len(t, report.ImagesDeleted, 2)
117
+		assert.Equal(t, uint64(9999), report.SpaceReclaimed)
118 118
 	}
119 119
 }
... ...
@@ -11,7 +11,7 @@ import (
11 11
 
12 12
 	"github.com/docker/docker/api/types"
13 13
 	"github.com/docker/docker/api/types/filters"
14
-	"github.com/docker/docker/pkg/testutil/assert"
14
+	"github.com/stretchr/testify/assert"
15 15
 	"golang.org/x/net/context"
16 16
 )
17 17
 
... ...
@@ -89,7 +89,7 @@ func TestNetworksPrune(t *testing.T) {
89 89
 				query := req.URL.Query()
90 90
 				for key, expected := range listCase.expectedQueryParams {
91 91
 					actual := query.Get(key)
92
-					assert.Equal(t, actual, expected)
92
+					assert.Equal(t, expected, actual)
93 93
 				}
94 94
 				content, err := json.Marshal(types.NetworksPruneReport{
95 95
 					NetworksDeleted: []string{"network_id1", "network_id2"},
... ...
@@ -106,7 +106,7 @@ func TestNetworksPrune(t *testing.T) {
106 106
 		}
107 107
 
108 108
 		report, err := client.NetworksPrune(context.Background(), listCase.filters)
109
-		assert.NilError(t, err)
110
-		assert.Equal(t, len(report.NetworksDeleted), 2)
109
+		assert.NoError(t, err)
110
+		assert.Len(t, report.NetworksDeleted, 2)
111 111
 	}
112 112
 }
... ...
@@ -5,7 +5,7 @@ package main
5 5
 import (
6 6
 	"testing"
7 7
 
8
-	"github.com/docker/docker/pkg/testutil/assert"
8
+	"github.com/stretchr/testify/assert"
9 9
 )
10 10
 
11 11
 func TestDaemonCommand(t *testing.T) {
... ...
@@ -13,5 +13,5 @@ func TestDaemonCommand(t *testing.T) {
13 13
 	cmd.SetArgs([]string{"--version"})
14 14
 	err := cmd.Execute()
15 15
 
16
-	assert.Error(t, err, "Please run `dockerd`")
16
+	assert.EqualError(t, err, "Please run `dockerd`")
17 17
 }
... ...
@@ -5,8 +5,8 @@ package main
5 5
 import (
6 6
 	"testing"
7 7
 
8
-	"github.com/docker/docker/pkg/testutil/assert"
9 8
 	"github.com/spf13/cobra"
9
+	"github.com/stretchr/testify/assert"
10 10
 )
11 11
 
12 12
 func stubRun(cmd *cobra.Command, args []string) error {
... ...
@@ -18,7 +18,7 @@ func TestDaemonCommandHelp(t *testing.T) {
18 18
 	cmd.RunE = stubRun
19 19
 	cmd.SetArgs([]string{"--help"})
20 20
 	err := cmd.Execute()
21
-	assert.NilError(t, err)
21
+	assert.NoError(t, err)
22 22
 }
23 23
 
24 24
 func TestDaemonCommand(t *testing.T) {
... ...
@@ -26,5 +26,5 @@ func TestDaemonCommand(t *testing.T) {
26 26
 	cmd.RunE = stubRun
27 27
 	cmd.SetArgs([]string{"--containerd", "/foo"})
28 28
 	err := cmd.Execute()
29
-	assert.NilError(t, err)
29
+	assert.NoError(t, err)
30 30
 }
... ...
@@ -8,7 +8,7 @@ import (
8 8
 	"github.com/Sirupsen/logrus"
9 9
 	"github.com/docker/docker/cli/command"
10 10
 	"github.com/docker/docker/cli/debug"
11
-	"github.com/docker/docker/pkg/testutil/assert"
11
+	"github.com/stretchr/testify/assert"
12 12
 )
13 13
 
14 14
 func TestClientDebugEnabled(t *testing.T) {
... ...
@@ -18,9 +18,9 @@ func TestClientDebugEnabled(t *testing.T) {
18 18
 	cmd.Flags().Set("debug", "true")
19 19
 
20 20
 	err := cmd.PersistentPreRunE(cmd, []string{})
21
-	assert.NilError(t, err)
22
-	assert.Equal(t, os.Getenv("DEBUG"), "1")
23
-	assert.Equal(t, logrus.GetLevel(), logrus.DebugLevel)
21
+	assert.NoError(t, err)
22
+	assert.Equal(t, "1", os.Getenv("DEBUG"))
23
+	assert.Equal(t, logrus.DebugLevel, logrus.GetLevel())
24 24
 }
25 25
 
26 26
 func TestExitStatusForInvalidSubcommandWithHelpFlag(t *testing.T) {
... ...
@@ -28,5 +28,5 @@ func TestExitStatusForInvalidSubcommandWithHelpFlag(t *testing.T) {
28 28
 	cmd := newDockerCommand(command.NewDockerCli(os.Stdin, discard, discard))
29 29
 	cmd.SetArgs([]string{"help", "invalid"})
30 30
 	err := cmd.Execute()
31
-	assert.Error(t, err, "unknown help topic: invalid")
31
+	assert.EqualError(t, err, "unknown help topic: invalid")
32 32
 }
... ...
@@ -7,8 +7,8 @@ import (
7 7
 	"testing"
8 8
 
9 9
 	"github.com/docker/docker/daemon/config"
10
-	"github.com/docker/docker/pkg/testutil/assert"
11 10
 	"github.com/spf13/pflag"
11
+	"github.com/stretchr/testify/assert"
12 12
 )
13 13
 
14 14
 func TestDaemonParseShmSize(t *testing.T) {
... ...
@@ -20,13 +20,7 @@ func TestDaemonParseShmSize(t *testing.T) {
20 20
 	conf := &config.Config{}
21 21
 	installConfigFlags(conf, flags)
22 22
 	// By default `--default-shm-size=64M`
23
-	expectedValue := 64 * 1024 * 1024
24
-	if conf.ShmSize.Value() != int64(expectedValue) {
25
-		t.Fatalf("expected default shm size %d, got %d", expectedValue, conf.ShmSize.Value())
26
-	}
27
-	assert.NilError(t, flags.Set("default-shm-size", "128M"))
28
-	expectedValue = 128 * 1024 * 1024
29
-	if conf.ShmSize.Value() != int64(expectedValue) {
30
-		t.Fatalf("expected default shm size %d, got %d", expectedValue, conf.ShmSize.Value())
31
-	}
23
+	assert.Equal(t, int64(64*1024*1024), conf.ShmSize.Value())
24
+	assert.NoError(t, flags.Set("default-shm-size", "128M"))
25
+	assert.Equal(t, int64(128*1024*1024), conf.ShmSize.Value())
32 26
 }
... ...
@@ -6,9 +6,11 @@ import (
6 6
 	"github.com/Sirupsen/logrus"
7 7
 	cliflags "github.com/docker/docker/cli/flags"
8 8
 	"github.com/docker/docker/daemon/config"
9
-	"github.com/docker/docker/pkg/testutil/assert"
9
+	"github.com/docker/docker/pkg/testutil"
10 10
 	"github.com/docker/docker/pkg/testutil/tempfile"
11 11
 	"github.com/spf13/pflag"
12
+	"github.com/stretchr/testify/assert"
13
+	"github.com/stretchr/testify/require"
12 14
 )
13 15
 
14 16
 func defaultOptions(configFile string) daemonOptions {
... ...
@@ -29,8 +31,8 @@ func TestLoadDaemonCliConfigWithoutOverriding(t *testing.T) {
29 29
 	opts.common.Debug = true
30 30
 
31 31
 	loadedConfig, err := loadDaemonCliConfig(opts)
32
-	assert.NilError(t, err)
33
-	assert.NotNil(t, loadedConfig)
32
+	require.NoError(t, err)
33
+	require.NotNil(t, loadedConfig)
34 34
 	if !loadedConfig.Debug {
35 35
 		t.Fatalf("expected debug to be copied from the common flags, got false")
36 36
 	}
... ...
@@ -42,9 +44,9 @@ func TestLoadDaemonCliConfigWithTLS(t *testing.T) {
42 42
 	opts.common.TLS = true
43 43
 
44 44
 	loadedConfig, err := loadDaemonCliConfig(opts)
45
-	assert.NilError(t, err)
46
-	assert.NotNil(t, loadedConfig)
47
-	assert.Equal(t, loadedConfig.CommonTLSOptions.CAFile, "/tmp/ca.pem")
45
+	require.NoError(t, err)
46
+	require.NotNil(t, loadedConfig)
47
+	assert.Equal(t, "/tmp/ca.pem", loadedConfig.CommonTLSOptions.CAFile)
48 48
 }
49 49
 
50 50
 func TestLoadDaemonCliConfigWithConflicts(t *testing.T) {
... ...
@@ -55,12 +57,12 @@ func TestLoadDaemonCliConfigWithConflicts(t *testing.T) {
55 55
 	opts := defaultOptions(configFile)
56 56
 	flags := opts.flags
57 57
 
58
-	assert.NilError(t, flags.Set("config-file", configFile))
59
-	assert.NilError(t, flags.Set("label", "l1=bar"))
60
-	assert.NilError(t, flags.Set("label", "l2=baz"))
58
+	assert.NoError(t, flags.Set("config-file", configFile))
59
+	assert.NoError(t, flags.Set("label", "l1=bar"))
60
+	assert.NoError(t, flags.Set("label", "l2=baz"))
61 61
 
62 62
 	_, err := loadDaemonCliConfig(opts)
63
-	assert.Error(t, err, "as a flag and in the configuration file: labels")
63
+	testutil.ErrorContains(t, err, "as a flag and in the configuration file: labels")
64 64
 }
65 65
 
66 66
 func TestLoadDaemonCliConfigWithTLSVerify(t *testing.T) {
... ...
@@ -71,8 +73,8 @@ func TestLoadDaemonCliConfigWithTLSVerify(t *testing.T) {
71 71
 	opts.common.TLSOptions.CAFile = "/tmp/ca.pem"
72 72
 
73 73
 	loadedConfig, err := loadDaemonCliConfig(opts)
74
-	assert.NilError(t, err)
75
-	assert.NotNil(t, loadedConfig)
74
+	require.NoError(t, err)
75
+	require.NotNil(t, loadedConfig)
76 76
 	assert.Equal(t, loadedConfig.TLS, true)
77 77
 }
78 78
 
... ...
@@ -84,9 +86,9 @@ func TestLoadDaemonCliConfigWithExplicitTLSVerifyFalse(t *testing.T) {
84 84
 	opts.common.TLSOptions.CAFile = "/tmp/ca.pem"
85 85
 
86 86
 	loadedConfig, err := loadDaemonCliConfig(opts)
87
-	assert.NilError(t, err)
88
-	assert.NotNil(t, loadedConfig)
89
-	assert.Equal(t, loadedConfig.TLS, true)
87
+	require.NoError(t, err)
88
+	require.NotNil(t, loadedConfig)
89
+	assert.True(t, loadedConfig.TLS)
90 90
 }
91 91
 
92 92
 func TestLoadDaemonCliConfigWithoutTLSVerify(t *testing.T) {
... ...
@@ -97,9 +99,9 @@ func TestLoadDaemonCliConfigWithoutTLSVerify(t *testing.T) {
97 97
 	opts.common.TLSOptions.CAFile = "/tmp/ca.pem"
98 98
 
99 99
 	loadedConfig, err := loadDaemonCliConfig(opts)
100
-	assert.NilError(t, err)
101
-	assert.NotNil(t, loadedConfig)
102
-	assert.Equal(t, loadedConfig.TLS, false)
100
+	require.NoError(t, err)
101
+	require.NotNil(t, loadedConfig)
102
+	assert.False(t, loadedConfig.TLS)
103 103
 }
104 104
 
105 105
 func TestLoadDaemonCliConfigWithLogLevel(t *testing.T) {
... ...
@@ -108,10 +110,10 @@ func TestLoadDaemonCliConfigWithLogLevel(t *testing.T) {
108 108
 
109 109
 	opts := defaultOptions(tempFile.Name())
110 110
 	loadedConfig, err := loadDaemonCliConfig(opts)
111
-	assert.NilError(t, err)
112
-	assert.NotNil(t, loadedConfig)
113
-	assert.Equal(t, loadedConfig.LogLevel, "warn")
114
-	assert.Equal(t, logrus.GetLevel(), logrus.WarnLevel)
111
+	require.NoError(t, err)
112
+	require.NotNil(t, loadedConfig)
113
+	assert.Equal(t, "warn", loadedConfig.LogLevel)
114
+	assert.Equal(t, logrus.WarnLevel, logrus.GetLevel())
115 115
 }
116 116
 
117 117
 func TestLoadDaemonConfigWithEmbeddedOptions(t *testing.T) {
... ...
@@ -121,10 +123,10 @@ func TestLoadDaemonConfigWithEmbeddedOptions(t *testing.T) {
121 121
 
122 122
 	opts := defaultOptions(tempFile.Name())
123 123
 	loadedConfig, err := loadDaemonCliConfig(opts)
124
-	assert.NilError(t, err)
125
-	assert.NotNil(t, loadedConfig)
126
-	assert.Equal(t, loadedConfig.CommonTLSOptions.CAFile, "/etc/certs/ca.pem")
127
-	assert.Equal(t, loadedConfig.LogConfig.Type, "syslog")
124
+	require.NoError(t, err)
125
+	require.NotNil(t, loadedConfig)
126
+	assert.Equal(t, "/etc/certs/ca.pem", loadedConfig.CommonTLSOptions.CAFile)
127
+	assert.Equal(t, "syslog", loadedConfig.LogConfig.Type)
128 128
 }
129 129
 
130 130
 func TestLoadDaemonConfigWithRegistryOptions(t *testing.T) {
... ...
@@ -137,9 +139,9 @@ func TestLoadDaemonConfigWithRegistryOptions(t *testing.T) {
137 137
 
138 138
 	opts := defaultOptions(tempFile.Name())
139 139
 	loadedConfig, err := loadDaemonCliConfig(opts)
140
-	assert.NilError(t, err)
141
-	assert.NotNil(t, loadedConfig)
140
+	require.NoError(t, err)
141
+	require.NotNil(t, loadedConfig)
142 142
 
143
-	assert.Equal(t, len(loadedConfig.Mirrors), 1)
144
-	assert.Equal(t, len(loadedConfig.InsecureRegistries), 1)
143
+	assert.Len(t, loadedConfig.Mirrors, 1)
144
+	assert.Len(t, loadedConfig.InsecureRegistries, 1)
145 145
 }
... ...
@@ -9,8 +9,9 @@ import (
9 9
 	"testing"
10 10
 
11 11
 	"github.com/docker/docker/daemon/config"
12
-	"github.com/docker/docker/pkg/testutil/assert"
13 12
 	"github.com/docker/docker/pkg/testutil/tempfile"
13
+	"github.com/stretchr/testify/assert"
14
+	"github.com/stretchr/testify/require"
14 15
 )
15 16
 
16 17
 func TestLoadDaemonCliConfigWithDaemonFlags(t *testing.T) {
... ...
@@ -21,17 +22,17 @@ func TestLoadDaemonCliConfigWithDaemonFlags(t *testing.T) {
21 21
 	opts := defaultOptions(tempFile.Name())
22 22
 	opts.common.Debug = true
23 23
 	opts.common.LogLevel = "info"
24
-	assert.NilError(t, opts.flags.Set("selinux-enabled", "true"))
24
+	assert.NoError(t, opts.flags.Set("selinux-enabled", "true"))
25 25
 
26 26
 	loadedConfig, err := loadDaemonCliConfig(opts)
27
-	assert.NilError(t, err)
28
-	assert.NotNil(t, loadedConfig)
29
-
30
-	assert.Equal(t, loadedConfig.Debug, true)
31
-	assert.Equal(t, loadedConfig.LogLevel, "info")
32
-	assert.Equal(t, loadedConfig.EnableSelinuxSupport, true)
33
-	assert.Equal(t, loadedConfig.LogConfig.Type, "json-file")
34
-	assert.Equal(t, loadedConfig.LogConfig.Config["max-size"], "1k")
27
+	require.NoError(t, err)
28
+	require.NotNil(t, loadedConfig)
29
+
30
+	assert.True(t, loadedConfig.Debug)
31
+	assert.Equal(t, "info", loadedConfig.LogLevel)
32
+	assert.True(t, loadedConfig.EnableSelinuxSupport)
33
+	assert.Equal(t, "json-file", loadedConfig.LogConfig.Type)
34
+	assert.Equal(t, "1k", loadedConfig.LogConfig.Config["max-size"])
35 35
 }
36 36
 
37 37
 func TestLoadDaemonConfigWithNetwork(t *testing.T) {
... ...
@@ -41,11 +42,11 @@ func TestLoadDaemonConfigWithNetwork(t *testing.T) {
41 41
 
42 42
 	opts := defaultOptions(tempFile.Name())
43 43
 	loadedConfig, err := loadDaemonCliConfig(opts)
44
-	assert.NilError(t, err)
45
-	assert.NotNil(t, loadedConfig)
44
+	require.NoError(t, err)
45
+	require.NotNil(t, loadedConfig)
46 46
 
47
-	assert.Equal(t, loadedConfig.IP, "127.0.0.2")
48
-	assert.Equal(t, loadedConfig.DefaultIP.String(), "127.0.0.1")
47
+	assert.Equal(t, "127.0.0.2", loadedConfig.IP)
48
+	assert.Equal(t, "127.0.0.1", loadedConfig.DefaultIP.String())
49 49
 }
50 50
 
51 51
 func TestLoadDaemonConfigWithMapOptions(t *testing.T) {
... ...
@@ -58,14 +59,14 @@ func TestLoadDaemonConfigWithMapOptions(t *testing.T) {
58 58
 
59 59
 	opts := defaultOptions(tempFile.Name())
60 60
 	loadedConfig, err := loadDaemonCliConfig(opts)
61
-	assert.NilError(t, err)
62
-	assert.NotNil(t, loadedConfig)
61
+	require.NoError(t, err)
62
+	require.NotNil(t, loadedConfig)
63 63
 	assert.NotNil(t, loadedConfig.ClusterOpts)
64 64
 
65 65
 	expectedPath := "/var/lib/docker/discovery_certs/ca.pem"
66
-	assert.Equal(t, loadedConfig.ClusterOpts["kv.cacertfile"], expectedPath)
66
+	assert.Equal(t, expectedPath, loadedConfig.ClusterOpts["kv.cacertfile"])
67 67
 	assert.NotNil(t, loadedConfig.LogConfig.Config)
68
-	assert.Equal(t, loadedConfig.LogConfig.Config["tag"], "test")
68
+	assert.Equal(t, "test", loadedConfig.LogConfig.Config["tag"])
69 69
 }
70 70
 
71 71
 func TestLoadDaemonConfigWithTrueDefaultValues(t *testing.T) {
... ...
@@ -75,18 +76,17 @@ func TestLoadDaemonConfigWithTrueDefaultValues(t *testing.T) {
75 75
 
76 76
 	opts := defaultOptions(tempFile.Name())
77 77
 	loadedConfig, err := loadDaemonCliConfig(opts)
78
-	assert.NilError(t, err)
79
-	assert.NotNil(t, loadedConfig)
80
-	assert.NotNil(t, loadedConfig.ClusterOpts)
78
+	require.NoError(t, err)
79
+	require.NotNil(t, loadedConfig)
81 80
 
82
-	assert.Equal(t, loadedConfig.EnableUserlandProxy, false)
81
+	assert.False(t, loadedConfig.EnableUserlandProxy)
83 82
 
84 83
 	// make sure reloading doesn't generate configuration
85 84
 	// conflicts after normalizing boolean values.
86 85
 	reload := func(reloadedConfig *config.Config) {
87
-		assert.Equal(t, reloadedConfig.EnableUserlandProxy, false)
86
+		assert.False(t, reloadedConfig.EnableUserlandProxy)
88 87
 	}
89
-	assert.NilError(t, config.Reload(opts.configFile, opts.flags, reload))
88
+	assert.NoError(t, config.Reload(opts.configFile, opts.flags, reload))
90 89
 }
91 90
 
92 91
 func TestLoadDaemonConfigWithTrueDefaultValuesLeaveDefaults(t *testing.T) {
... ...
@@ -95,11 +95,10 @@ func TestLoadDaemonConfigWithTrueDefaultValuesLeaveDefaults(t *testing.T) {
95 95
 
96 96
 	opts := defaultOptions(tempFile.Name())
97 97
 	loadedConfig, err := loadDaemonCliConfig(opts)
98
-	assert.NilError(t, err)
99
-	assert.NotNil(t, loadedConfig)
100
-	assert.NotNil(t, loadedConfig.ClusterOpts)
98
+	require.NoError(t, err)
99
+	require.NotNil(t, loadedConfig)
101 100
 
102
-	assert.Equal(t, loadedConfig.EnableUserlandProxy, true)
101
+	assert.True(t, loadedConfig.EnableUserlandProxy)
103 102
 }
104 103
 
105 104
 func TestLoadDaemonConfigWithLegacyRegistryOptions(t *testing.T) {
... ...
@@ -109,7 +108,7 @@ func TestLoadDaemonConfigWithLegacyRegistryOptions(t *testing.T) {
109 109
 
110 110
 	opts := defaultOptions(tempFile.Name())
111 111
 	loadedConfig, err := loadDaemonCliConfig(opts)
112
-	assert.NilError(t, err)
113
-	assert.NotNil(t, loadedConfig)
114
-	assert.Equal(t, loadedConfig.V2Only, true)
112
+	require.NoError(t, err)
113
+	require.NotNil(t, loadedConfig)
114
+	assert.True(t, loadedConfig.V2Only)
115 115
 }
... ...
@@ -9,8 +9,9 @@ import (
9 9
 
10 10
 	"github.com/docker/docker/daemon/discovery"
11 11
 	"github.com/docker/docker/opts"
12
-	"github.com/docker/docker/pkg/testutil/assert"
12
+	"github.com/docker/docker/pkg/testutil"
13 13
 	"github.com/spf13/pflag"
14
+	"github.com/stretchr/testify/assert"
14 15
 )
15 16
 
16 17
 func TestDaemonConfigurationNotFound(t *testing.T) {
... ...
@@ -61,9 +62,9 @@ func TestFindConfigurationConflicts(t *testing.T) {
61 61
 	flags := pflag.NewFlagSet("test", pflag.ContinueOnError)
62 62
 
63 63
 	flags.String("authorization-plugins", "", "")
64
-	assert.NilError(t, flags.Set("authorization-plugins", "asdf"))
64
+	assert.NoError(t, flags.Set("authorization-plugins", "asdf"))
65 65
 
66
-	assert.Error(t,
66
+	testutil.ErrorContains(t,
67 67
 		findConfigurationConflicts(config, flags),
68 68
 		"authorization-plugins: (from flag: asdf, from file: foobar)")
69 69
 }
... ...
@@ -74,10 +75,10 @@ func TestFindConfigurationConflictsWithNamedOptions(t *testing.T) {
74 74
 
75 75
 	var hosts []string
76 76
 	flags.VarP(opts.NewNamedListOptsRef("hosts", &hosts, opts.ValidateHost), "host", "H", "Daemon socket(s) to connect to")
77
-	assert.NilError(t, flags.Set("host", "tcp://127.0.0.1:4444"))
78
-	assert.NilError(t, flags.Set("host", "unix:///var/run/docker.sock"))
77
+	assert.NoError(t, flags.Set("host", "tcp://127.0.0.1:4444"))
78
+	assert.NoError(t, flags.Set("host", "unix:///var/run/docker.sock"))
79 79
 
80
-	assert.Error(t, findConfigurationConflicts(config, flags), "hosts")
80
+	testutil.ErrorContains(t, findConfigurationConflicts(config, flags), "hosts")
81 81
 }
82 82
 
83 83
 func TestDaemonConfigurationMergeConflicts(t *testing.T) {
... ...
@@ -9,12 +9,13 @@ import (
9 9
 	"github.com/docker/docker/api/types"
10 10
 	containertypes "github.com/docker/docker/api/types/container"
11 11
 	"github.com/docker/docker/container"
12
-	"github.com/docker/docker/pkg/testutil/assert"
12
+	"github.com/docker/docker/pkg/testutil"
13
+	"github.com/stretchr/testify/require"
13 14
 )
14 15
 
15 16
 func newDaemonWithTmpRoot(t *testing.T) (*Daemon, func()) {
16 17
 	tmp, err := ioutil.TempDir("", "docker-daemon-unix-test-")
17
-	assert.NilError(t, err)
18
+	require.NoError(t, err)
18 19
 	d := &Daemon{
19 20
 		repository: tmp,
20 21
 		root:       tmp,
... ...
@@ -40,8 +41,8 @@ func TestContainerDeletePaused(t *testing.T) {
40 40
 
41 41
 	err := d.ContainerRm(c.ID, &types.ContainerRmConfig{ForceRemove: false})
42 42
 
43
-	assert.Error(t, err, "cannot remove a paused container")
44
-	assert.Error(t, err, "Unpause and then stop the container before attempting removal or force remove")
43
+	testutil.ErrorContains(t, err, "cannot remove a paused container")
44
+	testutil.ErrorContains(t, err, "Unpause and then stop the container before attempting removal or force remove")
45 45
 }
46 46
 
47 47
 // TestContainerDeleteRestarting tests that a useful error message and instructions is given when attempting
... ...
@@ -63,8 +64,8 @@ func TestContainerDeleteRestarting(t *testing.T) {
63 63
 	d.containers.Add(c.ID, c)
64 64
 
65 65
 	err := d.ContainerRm(c.ID, &types.ContainerRmConfig{ForceRemove: false})
66
-	assert.Error(t, err, "cannot remove a restarting container")
67
-	assert.Error(t, err, "Stop the container before attempting removal or force remove")
66
+	testutil.ErrorContains(t, err, "cannot remove a restarting container")
67
+	testutil.ErrorContains(t, err, "Stop the container before attempting removal or force remove")
68 68
 }
69 69
 
70 70
 // TestContainerDeleteRunning tests that a useful error message and instructions is given when attempting
... ...
@@ -83,8 +84,7 @@ func TestContainerDeleteRunning(t *testing.T) {
83 83
 	d.containers.Add(c.ID, c)
84 84
 
85 85
 	err := d.ContainerRm(c.ID, &types.ContainerRmConfig{ForceRemove: false})
86
-	assert.Error(t, err, "cannot remove a running container")
87
-	assert.Error(t, err, "Stop the container before attempting removal or force remove")
86
+	testutil.ErrorContains(t, err, "cannot remove a running container")
88 87
 }
89 88
 
90 89
 func TestContainerDoubleDelete(t *testing.T) {
... ...
@@ -106,5 +106,5 @@ func TestContainerDoubleDelete(t *testing.T) {
106 106
 	// Try to remove the container when its state is removalInProgress.
107 107
 	// It should return an error indicating it is under removal progress.
108 108
 	err := d.ContainerRm(c.ID, &types.ContainerRmConfig{ForceRemove: true})
109
-	assert.Error(t, err, fmt.Sprintf("removal of container %s is already in progress", c.ID))
109
+	testutil.ErrorContains(t, err, fmt.Sprintf("removal of container %s is already in progress", c.ID))
110 110
 }
... ...
@@ -11,16 +11,17 @@ import (
11 11
 	"path/filepath"
12 12
 	"testing"
13 13
 
14
-	"github.com/docker/docker/pkg/testutil/assert"
14
+	"github.com/docker/docker/pkg/testutil"
15 15
 	"github.com/opencontainers/go-digest"
16
+	"github.com/stretchr/testify/assert"
16 17
 )
17 18
 
18 19
 func defaultFSStoreBackend(t *testing.T) (StoreBackend, func()) {
19 20
 	tmpdir, err := ioutil.TempDir("", "images-fs-store")
20
-	assert.NilError(t, err)
21
+	assert.NoError(t, err)
21 22
 
22 23
 	fsBackend, err := NewFSStoreBackend(tmpdir)
23
-	assert.NilError(t, err)
24
+	assert.NoError(t, err)
24 25
 
25 26
 	return fsBackend, func() { os.RemoveAll(tmpdir) }
26 27
 }
... ...
@@ -30,15 +31,15 @@ func TestFSGetInvalidData(t *testing.T) {
30 30
 	defer cleanup()
31 31
 
32 32
 	id, err := store.Set([]byte("foobar"))
33
-	assert.NilError(t, err)
33
+	assert.NoError(t, err)
34 34
 
35 35
 	dgst := digest.Digest(id)
36 36
 
37 37
 	err = ioutil.WriteFile(filepath.Join(store.(*fs).root, contentDirName, string(dgst.Algorithm()), dgst.Hex()), []byte("foobar2"), 0600)
38
-	assert.NilError(t, err)
38
+	assert.NoError(t, err)
39 39
 
40 40
 	_, err = store.Get(id)
41
-	assert.Error(t, err, "failed to verify")
41
+	testutil.ErrorContains(t, err, "failed to verify")
42 42
 }
43 43
 
44 44
 func TestFSInvalidSet(t *testing.T) {
... ...
@@ -47,15 +48,15 @@ func TestFSInvalidSet(t *testing.T) {
47 47
 
48 48
 	id := digest.FromBytes([]byte("foobar"))
49 49
 	err := os.Mkdir(filepath.Join(store.(*fs).root, contentDirName, string(id.Algorithm()), id.Hex()), 0700)
50
-	assert.NilError(t, err)
50
+	assert.NoError(t, err)
51 51
 
52 52
 	_, err = store.Set([]byte("foobar"))
53
-	assert.Error(t, err, "failed to write digest data")
53
+	testutil.ErrorContains(t, err, "failed to write digest data")
54 54
 }
55 55
 
56 56
 func TestFSInvalidRoot(t *testing.T) {
57 57
 	tmpdir, err := ioutil.TempDir("", "images-fs-store")
58
-	assert.NilError(t, err)
58
+	assert.NoError(t, err)
59 59
 	defer os.RemoveAll(tmpdir)
60 60
 
61 61
 	tcases := []struct {
... ...
@@ -70,14 +71,14 @@ func TestFSInvalidRoot(t *testing.T) {
70 70
 		root := filepath.Join(tmpdir, tc.root)
71 71
 		filePath := filepath.Join(tmpdir, tc.invalidFile)
72 72
 		err := os.MkdirAll(filepath.Dir(filePath), 0700)
73
-		assert.NilError(t, err)
73
+		assert.NoError(t, err)
74 74
 
75 75
 		f, err := os.Create(filePath)
76
-		assert.NilError(t, err)
76
+		assert.NoError(t, err)
77 77
 		f.Close()
78 78
 
79 79
 		_, err = NewFSStoreBackend(root)
80
-		assert.Error(t, err, "failed to create storage backend")
80
+		testutil.ErrorContains(t, err, "failed to create storage backend")
81 81
 
82 82
 		os.RemoveAll(root)
83 83
 	}
... ...
@@ -89,10 +90,10 @@ func TestFSMetadataGetSet(t *testing.T) {
89 89
 	defer cleanup()
90 90
 
91 91
 	id, err := store.Set([]byte("foo"))
92
-	assert.NilError(t, err)
92
+	assert.NoError(t, err)
93 93
 
94 94
 	id2, err := store.Set([]byte("bar"))
95
-	assert.NilError(t, err)
95
+	assert.NoError(t, err)
96 96
 
97 97
 	tcases := []struct {
98 98
 		id    digest.Digest
... ...
@@ -106,10 +107,10 @@ func TestFSMetadataGetSet(t *testing.T) {
106 106
 
107 107
 	for _, tc := range tcases {
108 108
 		err = store.SetMetadata(tc.id, tc.key, tc.value)
109
-		assert.NilError(t, err)
109
+		assert.NoError(t, err)
110 110
 
111 111
 		actual, err := store.GetMetadata(tc.id, tc.key)
112
-		assert.NilError(t, err)
112
+		assert.NoError(t, err)
113 113
 
114 114
 		if bytes.Compare(actual, tc.value) != 0 {
115 115
 			t.Fatalf("Metadata expected %q, got %q", tc.value, actual)
... ...
@@ -117,14 +118,14 @@ func TestFSMetadataGetSet(t *testing.T) {
117 117
 	}
118 118
 
119 119
 	_, err = store.GetMetadata(id2, "tkey2")
120
-	assert.Error(t, err, "failed to read metadata")
120
+	testutil.ErrorContains(t, err, "failed to read metadata")
121 121
 
122 122
 	id3 := digest.FromBytes([]byte("baz"))
123 123
 	err = store.SetMetadata(id3, "tkey", []byte("tval"))
124
-	assert.Error(t, err, "failed to get digest")
124
+	testutil.ErrorContains(t, err, "failed to get digest")
125 125
 
126 126
 	_, err = store.GetMetadata(id3, "tkey")
127
-	assert.Error(t, err, "failed to get digest")
127
+	testutil.ErrorContains(t, err, "failed to get digest")
128 128
 }
129 129
 
130 130
 func TestFSInvalidWalker(t *testing.T) {
... ...
@@ -132,19 +133,19 @@ func TestFSInvalidWalker(t *testing.T) {
132 132
 	defer cleanup()
133 133
 
134 134
 	fooID, err := store.Set([]byte("foo"))
135
-	assert.NilError(t, err)
135
+	assert.NoError(t, err)
136 136
 
137 137
 	err = ioutil.WriteFile(filepath.Join(store.(*fs).root, contentDirName, "sha256/foobar"), []byte("foobar"), 0600)
138
-	assert.NilError(t, err)
138
+	assert.NoError(t, err)
139 139
 
140 140
 	n := 0
141 141
 	err = store.Walk(func(id digest.Digest) error {
142
-		assert.Equal(t, id, fooID)
142
+		assert.Equal(t, fooID, id)
143 143
 		n++
144 144
 		return nil
145 145
 	})
146
-	assert.NilError(t, err)
147
-	assert.Equal(t, n, 1)
146
+	assert.NoError(t, err)
147
+	assert.Equal(t, 1, n)
148 148
 }
149 149
 
150 150
 func TestFSGetSet(t *testing.T) {
... ...
@@ -161,12 +162,12 @@ func TestFSGetSet(t *testing.T) {
161 161
 
162 162
 	randomInput := make([]byte, 8*1024)
163 163
 	_, err := rand.Read(randomInput)
164
-	assert.NilError(t, err)
164
+	assert.NoError(t, err)
165 165
 
166 166
 	// skipping use of digest pkg because it is used by the implementation
167 167
 	h := sha256.New()
168 168
 	_, err = h.Write(randomInput)
169
-	assert.NilError(t, err)
169
+	assert.NoError(t, err)
170 170
 
171 171
 	tcases = append(tcases, tcase{
172 172
 		input:    randomInput,
... ...
@@ -175,13 +176,13 @@ func TestFSGetSet(t *testing.T) {
175 175
 
176 176
 	for _, tc := range tcases {
177 177
 		id, err := store.Set([]byte(tc.input))
178
-		assert.NilError(t, err)
179
-		assert.Equal(t, id, tc.expected)
178
+		assert.NoError(t, err)
179
+		assert.Equal(t, tc.expected, id)
180 180
 	}
181 181
 
182 182
 	for _, tc := range tcases {
183 183
 		data, err := store.Get(tc.expected)
184
-		assert.NilError(t, err)
184
+		assert.NoError(t, err)
185 185
 		if bytes.Compare(data, tc.input) != 0 {
186 186
 			t.Fatalf("expected data %q, got %q", tc.input, data)
187 187
 		}
... ...
@@ -194,7 +195,7 @@ func TestFSGetUnsetKey(t *testing.T) {
194 194
 
195 195
 	for _, key := range []digest.Digest{"foobar:abc", "sha256:abc", "sha256:c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2a"} {
196 196
 		_, err := store.Get(key)
197
-		assert.Error(t, err, "failed to get digest")
197
+		testutil.ErrorContains(t, err, "failed to get digest")
198 198
 	}
199 199
 }
200 200
 
... ...
@@ -204,7 +205,7 @@ func TestFSGetEmptyData(t *testing.T) {
204 204
 
205 205
 	for _, emptyData := range [][]byte{nil, {}} {
206 206
 		_, err := store.Set(emptyData)
207
-		assert.Error(t, err, "invalid empty data")
207
+		testutil.ErrorContains(t, err, "invalid empty data")
208 208
 	}
209 209
 }
210 210
 
... ...
@@ -213,25 +214,25 @@ func TestFSDelete(t *testing.T) {
213 213
 	defer cleanup()
214 214
 
215 215
 	id, err := store.Set([]byte("foo"))
216
-	assert.NilError(t, err)
216
+	assert.NoError(t, err)
217 217
 
218 218
 	id2, err := store.Set([]byte("bar"))
219
-	assert.NilError(t, err)
219
+	assert.NoError(t, err)
220 220
 
221 221
 	err = store.Delete(id)
222
-	assert.NilError(t, err)
222
+	assert.NoError(t, err)
223 223
 
224 224
 	_, err = store.Get(id)
225
-	assert.Error(t, err, "failed to get digest")
225
+	testutil.ErrorContains(t, err, "failed to get digest")
226 226
 
227 227
 	_, err = store.Get(id2)
228
-	assert.NilError(t, err)
228
+	assert.NoError(t, err)
229 229
 
230 230
 	err = store.Delete(id2)
231
-	assert.NilError(t, err)
231
+	assert.NoError(t, err)
232 232
 
233 233
 	_, err = store.Get(id2)
234
-	assert.Error(t, err, "failed to get digest")
234
+	testutil.ErrorContains(t, err, "failed to get digest")
235 235
 }
236 236
 
237 237
 func TestFSWalker(t *testing.T) {
... ...
@@ -239,10 +240,10 @@ func TestFSWalker(t *testing.T) {
239 239
 	defer cleanup()
240 240
 
241 241
 	id, err := store.Set([]byte("foo"))
242
-	assert.NilError(t, err)
242
+	assert.NoError(t, err)
243 243
 
244 244
 	id2, err := store.Set([]byte("bar"))
245
-	assert.NilError(t, err)
245
+	assert.NoError(t, err)
246 246
 
247 247
 	tcases := make(map[digest.Digest]struct{})
248 248
 	tcases[id] = struct{}{}
... ...
@@ -253,9 +254,9 @@ func TestFSWalker(t *testing.T) {
253 253
 		n++
254 254
 		return nil
255 255
 	})
256
-	assert.NilError(t, err)
257
-	assert.Equal(t, n, 2)
258
-	assert.Equal(t, len(tcases), 0)
256
+	assert.NoError(t, err)
257
+	assert.Equal(t, 2, n)
258
+	assert.Len(t, tcases, 0)
259 259
 }
260 260
 
261 261
 func TestFSWalkerStopOnError(t *testing.T) {
... ...
@@ -263,12 +264,12 @@ func TestFSWalkerStopOnError(t *testing.T) {
263 263
 	defer cleanup()
264 264
 
265 265
 	id, err := store.Set([]byte("foo"))
266
-	assert.NilError(t, err)
266
+	assert.NoError(t, err)
267 267
 
268 268
 	tcases := make(map[digest.Digest]struct{})
269 269
 	tcases[id] = struct{}{}
270 270
 	err = store.Walk(func(id digest.Digest) error {
271 271
 		return errors.New("what")
272 272
 	})
273
-	assert.Error(t, err, "what")
273
+	testutil.ErrorContains(t, err, "what")
274 274
 }
... ...
@@ -6,7 +6,8 @@ import (
6 6
 	"strings"
7 7
 	"testing"
8 8
 
9
-	"github.com/docker/docker/pkg/testutil/assert"
9
+	"github.com/stretchr/testify/assert"
10
+	"github.com/stretchr/testify/require"
10 11
 )
11 12
 
12 13
 const sampleImageJSON = `{
... ...
@@ -21,13 +22,13 @@ const sampleImageJSON = `{
21 21
 
22 22
 func TestNewFromJSON(t *testing.T) {
23 23
 	img, err := NewFromJSON([]byte(sampleImageJSON))
24
-	assert.NilError(t, err)
25
-	assert.Equal(t, string(img.RawJSON()), sampleImageJSON)
24
+	require.NoError(t, err)
25
+	assert.Equal(t, sampleImageJSON, string(img.RawJSON()))
26 26
 }
27 27
 
28 28
 func TestNewFromJSONWithInvalidJSON(t *testing.T) {
29 29
 	_, err := NewFromJSON([]byte("{}"))
30
-	assert.Error(t, err, "invalid image JSON, no RootFS key")
30
+	assert.EqualError(t, err, "invalid image JSON, no RootFS key")
31 31
 }
32 32
 
33 33
 func TestMarshalKeyOrder(t *testing.T) {
... ...
@@ -38,7 +39,7 @@ func TestMarshalKeyOrder(t *testing.T) {
38 38
 			Architecture: "c",
39 39
 		},
40 40
 	})
41
-	assert.NilError(t, err)
41
+	assert.NoError(t, err)
42 42
 
43 43
 	expectedOrder := []string{"architecture", "author", "comment"}
44 44
 	var indexes []int
... ...
@@ -4,8 +4,9 @@ import (
4 4
 	"testing"
5 5
 
6 6
 	"github.com/docker/docker/layer"
7
-	"github.com/docker/docker/pkg/testutil/assert"
7
+	"github.com/docker/docker/pkg/testutil"
8 8
 	"github.com/opencontainers/go-digest"
9
+	"github.com/stretchr/testify/assert"
9 10
 )
10 11
 
11 12
 func TestRestore(t *testing.T) {
... ...
@@ -13,55 +14,55 @@ func TestRestore(t *testing.T) {
13 13
 	defer cleanup()
14 14
 
15 15
 	id1, err := fs.Set([]byte(`{"comment": "abc", "rootfs": {"type": "layers"}}`))
16
-	assert.NilError(t, err)
16
+	assert.NoError(t, err)
17 17
 
18 18
 	_, err = fs.Set([]byte(`invalid`))
19
-	assert.NilError(t, err)
19
+	assert.NoError(t, err)
20 20
 
21 21
 	id2, err := fs.Set([]byte(`{"comment": "def", "rootfs": {"type": "layers", "diff_ids": ["2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae"]}}`))
22
-	assert.NilError(t, err)
22
+	assert.NoError(t, err)
23 23
 
24 24
 	err = fs.SetMetadata(id2, "parent", []byte(id1))
25
-	assert.NilError(t, err)
25
+	assert.NoError(t, err)
26 26
 
27 27
 	is, err := NewImageStore(fs, &mockLayerGetReleaser{})
28
-	assert.NilError(t, err)
28
+	assert.NoError(t, err)
29 29
 
30
-	assert.Equal(t, len(is.Map()), 2)
30
+	assert.Len(t, is.Map(), 2)
31 31
 
32 32
 	img1, err := is.Get(ID(id1))
33
-	assert.NilError(t, err)
34
-	assert.Equal(t, img1.computedID, ID(id1))
35
-	assert.Equal(t, img1.computedID.String(), string(id1))
33
+	assert.NoError(t, err)
34
+	assert.Equal(t, ID(id1), img1.computedID)
35
+	assert.Equal(t, string(id1), img1.computedID.String())
36 36
 
37 37
 	img2, err := is.Get(ID(id2))
38
-	assert.NilError(t, err)
39
-	assert.Equal(t, img1.Comment, "abc")
40
-	assert.Equal(t, img2.Comment, "def")
38
+	assert.NoError(t, err)
39
+	assert.Equal(t, "abc", img1.Comment)
40
+	assert.Equal(t, "def", img2.Comment)
41 41
 
42 42
 	p, err := is.GetParent(ID(id1))
43
-	assert.Error(t, err, "failed to read metadata")
43
+	testutil.ErrorContains(t, err, "failed to read metadata")
44 44
 
45 45
 	p, err = is.GetParent(ID(id2))
46
-	assert.NilError(t, err)
47
-	assert.Equal(t, p, ID(id1))
46
+	assert.NoError(t, err)
47
+	assert.Equal(t, ID(id1), p)
48 48
 
49 49
 	children := is.Children(ID(id1))
50
-	assert.Equal(t, len(children), 1)
51
-	assert.Equal(t, children[0], ID(id2))
52
-	assert.Equal(t, len(is.Heads()), 1)
50
+	assert.Len(t, children, 1)
51
+	assert.Equal(t, ID(id2), children[0])
52
+	assert.Len(t, is.Heads(), 1)
53 53
 
54 54
 	sid1, err := is.Search(string(id1)[:10])
55
-	assert.NilError(t, err)
56
-	assert.Equal(t, sid1, ID(id1))
55
+	assert.NoError(t, err)
56
+	assert.Equal(t, ID(id1), sid1)
57 57
 
58 58
 	sid1, err = is.Search(digest.Digest(id1).Hex()[:6])
59
-	assert.NilError(t, err)
60
-	assert.Equal(t, sid1, ID(id1))
59
+	assert.NoError(t, err)
60
+	assert.Equal(t, ID(id1), sid1)
61 61
 
62 62
 	invalidPattern := digest.Digest(id1).Hex()[1:6]
63 63
 	_, err = is.Search(invalidPattern)
64
-	assert.Error(t, err, "No such image")
64
+	testutil.ErrorContains(t, err, "No such image")
65 65
 }
66 66
 
67 67
 func TestAddDelete(t *testing.T) {
... ...
@@ -69,34 +70,34 @@ func TestAddDelete(t *testing.T) {
69 69
 	defer cleanup()
70 70
 
71 71
 	id1, err := is.Create([]byte(`{"comment": "abc", "rootfs": {"type": "layers", "diff_ids": ["2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae"]}}`))
72
-	assert.NilError(t, err)
73
-	assert.Equal(t, id1, ID("sha256:8d25a9c45df515f9d0fe8e4a6b1c64dd3b965a84790ddbcc7954bb9bc89eb993"))
72
+	assert.NoError(t, err)
73
+	assert.Equal(t, ID("sha256:8d25a9c45df515f9d0fe8e4a6b1c64dd3b965a84790ddbcc7954bb9bc89eb993"), id1)
74 74
 
75 75
 	img, err := is.Get(id1)
76
-	assert.NilError(t, err)
77
-	assert.Equal(t, img.Comment, "abc")
76
+	assert.NoError(t, err)
77
+	assert.Equal(t, "abc", img.Comment)
78 78
 
79 79
 	id2, err := is.Create([]byte(`{"comment": "def", "rootfs": {"type": "layers", "diff_ids": ["2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae"]}}`))
80
-	assert.NilError(t, err)
80
+	assert.NoError(t, err)
81 81
 
82 82
 	err = is.SetParent(id2, id1)
83
-	assert.NilError(t, err)
83
+	assert.NoError(t, err)
84 84
 
85 85
 	pid1, err := is.GetParent(id2)
86
-	assert.NilError(t, err)
86
+	assert.NoError(t, err)
87 87
 	assert.Equal(t, pid1, id1)
88 88
 
89 89
 	_, err = is.Delete(id1)
90
-	assert.NilError(t, err)
90
+	assert.NoError(t, err)
91 91
 
92 92
 	_, err = is.Get(id1)
93
-	assert.Error(t, err, "failed to get digest")
93
+	testutil.ErrorContains(t, err, "failed to get digest")
94 94
 
95 95
 	_, err = is.Get(id2)
96
-	assert.NilError(t, err)
96
+	assert.NoError(t, err)
97 97
 
98 98
 	_, err = is.GetParent(id2)
99
-	assert.Error(t, err, "failed to read metadata")
99
+	testutil.ErrorContains(t, err, "failed to read metadata")
100 100
 }
101 101
 
102 102
 func TestSearchAfterDelete(t *testing.T) {
... ...
@@ -104,17 +105,17 @@ func TestSearchAfterDelete(t *testing.T) {
104 104
 	defer cleanup()
105 105
 
106 106
 	id, err := is.Create([]byte(`{"comment": "abc", "rootfs": {"type": "layers"}}`))
107
-	assert.NilError(t, err)
107
+	assert.NoError(t, err)
108 108
 
109 109
 	id1, err := is.Search(string(id)[:15])
110
-	assert.NilError(t, err)
110
+	assert.NoError(t, err)
111 111
 	assert.Equal(t, id1, id)
112 112
 
113 113
 	_, err = is.Delete(id)
114
-	assert.NilError(t, err)
114
+	assert.NoError(t, err)
115 115
 
116 116
 	_, err = is.Search(string(id)[:15])
117
-	assert.Error(t, err, "No such image")
117
+	testutil.ErrorContains(t, err, "No such image")
118 118
 }
119 119
 
120 120
 func TestParentReset(t *testing.T) {
... ...
@@ -122,27 +123,27 @@ func TestParentReset(t *testing.T) {
122 122
 	defer cleanup()
123 123
 
124 124
 	id, err := is.Create([]byte(`{"comment": "abc1", "rootfs": {"type": "layers"}}`))
125
-	assert.NilError(t, err)
125
+	assert.NoError(t, err)
126 126
 
127 127
 	id2, err := is.Create([]byte(`{"comment": "abc2", "rootfs": {"type": "layers"}}`))
128
-	assert.NilError(t, err)
128
+	assert.NoError(t, err)
129 129
 
130 130
 	id3, err := is.Create([]byte(`{"comment": "abc3", "rootfs": {"type": "layers"}}`))
131
-	assert.NilError(t, err)
131
+	assert.NoError(t, err)
132 132
 
133
-	assert.NilError(t, is.SetParent(id, id2))
134
-	assert.Equal(t, len(is.Children(id2)), 1)
133
+	assert.NoError(t, is.SetParent(id, id2))
134
+	assert.Len(t, is.Children(id2), 1)
135 135
 
136
-	assert.NilError(t, is.SetParent(id, id3))
137
-	assert.Equal(t, len(is.Children(id2)), 0)
138
-	assert.Equal(t, len(is.Children(id3)), 1)
136
+	assert.NoError(t, is.SetParent(id, id3))
137
+	assert.Len(t, is.Children(id2), 0)
138
+	assert.Len(t, is.Children(id3), 1)
139 139
 }
140 140
 
141 141
 func defaultImageStore(t *testing.T) (Store, func()) {
142 142
 	fsBackend, cleanup := defaultFSStoreBackend(t)
143 143
 
144 144
 	store, err := NewImageStore(fsBackend, &mockLayerGetReleaser{})
145
-	assert.NilError(t, err)
145
+	assert.NoError(t, err)
146 146
 
147 147
 	return store, cleanup
148 148
 }
... ...
@@ -5,7 +5,9 @@ import (
5 5
 	"testing"
6 6
 
7 7
 	mounttypes "github.com/docker/docker/api/types/mount"
8
-	"github.com/docker/docker/pkg/testutil/assert"
8
+	"github.com/docker/docker/pkg/testutil"
9
+	"github.com/stretchr/testify/assert"
10
+	"github.com/stretchr/testify/require"
9 11
 )
10 12
 
11 13
 func TestMountOptString(t *testing.T) {
... ...
@@ -24,7 +26,7 @@ func TestMountOptString(t *testing.T) {
24 24
 		},
25 25
 	}
26 26
 	expected := "bind /home/path /target, volume foo /target/foo"
27
-	assert.Equal(t, mount.String(), expected)
27
+	assert.Equal(t, expected, mount.String())
28 28
 }
29 29
 
30 30
 func TestMountOptSetBindNoErrorBind(t *testing.T) {
... ...
@@ -37,15 +39,15 @@ func TestMountOptSetBindNoErrorBind(t *testing.T) {
37 37
 	} {
38 38
 		var mount MountOpt
39 39
 
40
-		assert.NilError(t, mount.Set(testcase))
40
+		assert.NoError(t, mount.Set(testcase))
41 41
 
42 42
 		mounts := mount.Value()
43
-		assert.Equal(t, len(mounts), 1)
44
-		assert.Equal(t, mounts[0], mounttypes.Mount{
43
+		require.Len(t, mounts, 1)
44
+		assert.Equal(t, mounttypes.Mount{
45 45
 			Type:   mounttypes.TypeBind,
46 46
 			Source: "/source",
47 47
 			Target: "/target",
48
-		})
48
+		}, mounts[0])
49 49
 	}
50 50
 }
51 51
 
... ...
@@ -59,15 +61,15 @@ func TestMountOptSetVolumeNoError(t *testing.T) {
59 59
 	} {
60 60
 		var mount MountOpt
61 61
 
62
-		assert.NilError(t, mount.Set(testcase))
62
+		assert.NoError(t, mount.Set(testcase))
63 63
 
64 64
 		mounts := mount.Value()
65
-		assert.Equal(t, len(mounts), 1)
66
-		assert.Equal(t, mounts[0], mounttypes.Mount{
65
+		require.Len(t, mounts, 1)
66
+		assert.Equal(t, mounttypes.Mount{
67 67
 			Type:   mounttypes.TypeVolume,
68 68
 			Source: "/source",
69 69
 			Target: "/target",
70
-		})
70
+		}, mounts[0])
71 71
 	}
72 72
 }
73 73
 
... ...
@@ -75,82 +77,82 @@ func TestMountOptSetVolumeNoError(t *testing.T) {
75 75
 // volume mount.
76 76
 func TestMountOptDefaultType(t *testing.T) {
77 77
 	var mount MountOpt
78
-	assert.NilError(t, mount.Set("target=/target,source=/foo"))
79
-	assert.Equal(t, mount.values[0].Type, mounttypes.TypeVolume)
78
+	assert.NoError(t, mount.Set("target=/target,source=/foo"))
79
+	assert.Equal(t, mounttypes.TypeVolume, mount.values[0].Type)
80 80
 }
81 81
 
82 82
 func TestMountOptSetErrorNoTarget(t *testing.T) {
83 83
 	var mount MountOpt
84
-	assert.Error(t, mount.Set("type=volume,source=/foo"), "target is required")
84
+	assert.EqualError(t, mount.Set("type=volume,source=/foo"), "target is required")
85 85
 }
86 86
 
87 87
 func TestMountOptSetErrorInvalidKey(t *testing.T) {
88 88
 	var mount MountOpt
89
-	assert.Error(t, mount.Set("type=volume,bogus=foo"), "unexpected key 'bogus'")
89
+	assert.EqualError(t, mount.Set("type=volume,bogus=foo"), "unexpected key 'bogus' in 'bogus=foo'")
90 90
 }
91 91
 
92 92
 func TestMountOptSetErrorInvalidField(t *testing.T) {
93 93
 	var mount MountOpt
94
-	assert.Error(t, mount.Set("type=volume,bogus"), "invalid field 'bogus'")
94
+	assert.EqualError(t, mount.Set("type=volume,bogus"), "invalid field 'bogus' must be a key=value pair")
95 95
 }
96 96
 
97 97
 func TestMountOptSetErrorInvalidReadOnly(t *testing.T) {
98 98
 	var mount MountOpt
99
-	assert.Error(t, mount.Set("type=volume,readonly=no"), "invalid value for readonly: no")
100
-	assert.Error(t, mount.Set("type=volume,readonly=invalid"), "invalid value for readonly: invalid")
99
+	assert.EqualError(t, mount.Set("type=volume,readonly=no"), "invalid value for readonly: no")
100
+	assert.EqualError(t, mount.Set("type=volume,readonly=invalid"), "invalid value for readonly: invalid")
101 101
 }
102 102
 
103 103
 func TestMountOptDefaultEnableReadOnly(t *testing.T) {
104 104
 	var m MountOpt
105
-	assert.NilError(t, m.Set("type=bind,target=/foo,source=/foo"))
106
-	assert.Equal(t, m.values[0].ReadOnly, false)
105
+	assert.NoError(t, m.Set("type=bind,target=/foo,source=/foo"))
106
+	assert.False(t, m.values[0].ReadOnly)
107 107
 
108 108
 	m = MountOpt{}
109
-	assert.NilError(t, m.Set("type=bind,target=/foo,source=/foo,readonly"))
110
-	assert.Equal(t, m.values[0].ReadOnly, true)
109
+	assert.NoError(t, m.Set("type=bind,target=/foo,source=/foo,readonly"))
110
+	assert.True(t, m.values[0].ReadOnly)
111 111
 
112 112
 	m = MountOpt{}
113
-	assert.NilError(t, m.Set("type=bind,target=/foo,source=/foo,readonly=1"))
114
-	assert.Equal(t, m.values[0].ReadOnly, true)
113
+	assert.NoError(t, m.Set("type=bind,target=/foo,source=/foo,readonly=1"))
114
+	assert.True(t, m.values[0].ReadOnly)
115 115
 
116 116
 	m = MountOpt{}
117
-	assert.NilError(t, m.Set("type=bind,target=/foo,source=/foo,readonly=true"))
118
-	assert.Equal(t, m.values[0].ReadOnly, true)
117
+	assert.NoError(t, m.Set("type=bind,target=/foo,source=/foo,readonly=true"))
118
+	assert.True(t, m.values[0].ReadOnly)
119 119
 
120 120
 	m = MountOpt{}
121
-	assert.NilError(t, m.Set("type=bind,target=/foo,source=/foo,readonly=0"))
122
-	assert.Equal(t, m.values[0].ReadOnly, false)
121
+	assert.NoError(t, m.Set("type=bind,target=/foo,source=/foo,readonly=0"))
122
+	assert.False(t, m.values[0].ReadOnly)
123 123
 }
124 124
 
125 125
 func TestMountOptVolumeNoCopy(t *testing.T) {
126 126
 	var m MountOpt
127
-	assert.NilError(t, m.Set("type=volume,target=/foo,volume-nocopy"))
128
-	assert.Equal(t, m.values[0].Source, "")
127
+	assert.NoError(t, m.Set("type=volume,target=/foo,volume-nocopy"))
128
+	assert.Equal(t, "", m.values[0].Source)
129 129
 
130 130
 	m = MountOpt{}
131
-	assert.NilError(t, m.Set("type=volume,target=/foo,source=foo"))
132
-	assert.Equal(t, m.values[0].VolumeOptions == nil, true)
131
+	assert.NoError(t, m.Set("type=volume,target=/foo,source=foo"))
132
+	assert.True(t, m.values[0].VolumeOptions == nil)
133 133
 
134 134
 	m = MountOpt{}
135
-	assert.NilError(t, m.Set("type=volume,target=/foo,source=foo,volume-nocopy=true"))
136
-	assert.Equal(t, m.values[0].VolumeOptions != nil, true)
137
-	assert.Equal(t, m.values[0].VolumeOptions.NoCopy, true)
135
+	assert.NoError(t, m.Set("type=volume,target=/foo,source=foo,volume-nocopy=true"))
136
+	assert.True(t, m.values[0].VolumeOptions != nil)
137
+	assert.True(t, m.values[0].VolumeOptions.NoCopy)
138 138
 
139 139
 	m = MountOpt{}
140
-	assert.NilError(t, m.Set("type=volume,target=/foo,source=foo,volume-nocopy"))
141
-	assert.Equal(t, m.values[0].VolumeOptions != nil, true)
142
-	assert.Equal(t, m.values[0].VolumeOptions.NoCopy, true)
140
+	assert.NoError(t, m.Set("type=volume,target=/foo,source=foo,volume-nocopy"))
141
+	assert.True(t, m.values[0].VolumeOptions != nil)
142
+	assert.True(t, m.values[0].VolumeOptions.NoCopy)
143 143
 
144 144
 	m = MountOpt{}
145
-	assert.NilError(t, m.Set("type=volume,target=/foo,source=foo,volume-nocopy=1"))
146
-	assert.Equal(t, m.values[0].VolumeOptions != nil, true)
147
-	assert.Equal(t, m.values[0].VolumeOptions.NoCopy, true)
145
+	assert.NoError(t, m.Set("type=volume,target=/foo,source=foo,volume-nocopy=1"))
146
+	assert.True(t, m.values[0].VolumeOptions != nil)
147
+	assert.True(t, m.values[0].VolumeOptions.NoCopy)
148 148
 }
149 149
 
150 150
 func TestMountOptTypeConflict(t *testing.T) {
151 151
 	var m MountOpt
152
-	assert.Error(t, m.Set("type=bind,target=/foo,source=/foo,volume-nocopy=true"), "cannot mix")
153
-	assert.Error(t, m.Set("type=volume,target=/foo,source=/foo,bind-propagation=rprivate"), "cannot mix")
152
+	testutil.ErrorContains(t, m.Set("type=bind,target=/foo,source=/foo,volume-nocopy=true"), "cannot mix")
153
+	testutil.ErrorContains(t, m.Set("type=volume,target=/foo,source=/foo,bind-propagation=rprivate"), "cannot mix")
154 154
 }
155 155
 
156 156
 func TestMountOptSetTmpfsNoError(t *testing.T) {
... ...
@@ -161,24 +163,24 @@ func TestMountOptSetTmpfsNoError(t *testing.T) {
161 161
 	} {
162 162
 		var mount MountOpt
163 163
 
164
-		assert.NilError(t, mount.Set(testcase))
164
+		assert.NoError(t, mount.Set(testcase))
165 165
 
166 166
 		mounts := mount.Value()
167
-		assert.Equal(t, len(mounts), 1)
168
-		assert.DeepEqual(t, mounts[0], mounttypes.Mount{
167
+		require.Len(t, mounts, 1)
168
+		assert.Equal(t, mounttypes.Mount{
169 169
 			Type:   mounttypes.TypeTmpfs,
170 170
 			Target: "/target",
171 171
 			TmpfsOptions: &mounttypes.TmpfsOptions{
172 172
 				SizeBytes: 1024 * 1024, // not 1000 * 1000
173 173
 				Mode:      os.FileMode(0700),
174 174
 			},
175
-		})
175
+		}, mounts[0])
176 176
 	}
177 177
 }
178 178
 
179 179
 func TestMountOptSetTmpfsError(t *testing.T) {
180 180
 	var m MountOpt
181
-	assert.Error(t, m.Set("type=tmpfs,target=/foo,tmpfs-size=foo"), "invalid value for tmpfs-size")
182
-	assert.Error(t, m.Set("type=tmpfs,target=/foo,tmpfs-mode=foo"), "invalid value for tmpfs-mode")
183
-	assert.Error(t, m.Set("type=tmpfs"), "target is required")
181
+	testutil.ErrorContains(t, m.Set("type=tmpfs,target=/foo,tmpfs-size=foo"), "invalid value for tmpfs-size")
182
+	testutil.ErrorContains(t, m.Set("type=tmpfs,target=/foo,tmpfs-mode=foo"), "invalid value for tmpfs-mode")
183
+	testutil.ErrorContains(t, m.Set("type=tmpfs"), "target is required")
184 184
 }
... ...
@@ -4,7 +4,8 @@ import (
4 4
 	"testing"
5 5
 
6 6
 	"github.com/docker/docker/api/types/swarm"
7
-	"github.com/docker/docker/pkg/testutil/assert"
7
+	"github.com/docker/docker/pkg/testutil"
8
+	"github.com/stretchr/testify/assert"
8 9
 )
9 10
 
10 11
 func TestPortOptValidSimpleSyntax(t *testing.T) {
... ...
@@ -98,8 +99,8 @@ func TestPortOptValidSimpleSyntax(t *testing.T) {
98 98
 	}
99 99
 	for _, tc := range testCases {
100 100
 		var port PortOpt
101
-		assert.NilError(t, port.Set(tc.value))
102
-		assert.Equal(t, len(port.Value()), len(tc.expected))
101
+		assert.NoError(t, port.Set(tc.value))
102
+		assert.Len(t, port.Value(), len(tc.expected))
103 103
 		for _, expectedPortConfig := range tc.expected {
104 104
 			assertContains(t, port.Value(), expectedPortConfig)
105 105
 		}
... ...
@@ -189,8 +190,8 @@ func TestPortOptValidComplexSyntax(t *testing.T) {
189 189
 	}
190 190
 	for _, tc := range testCases {
191 191
 		var port PortOpt
192
-		assert.NilError(t, port.Set(tc.value))
193
-		assert.Equal(t, len(port.Value()), len(tc.expected))
192
+		assert.NoError(t, port.Set(tc.value))
193
+		assert.Len(t, port.Value(), len(tc.expected))
194 194
 		for _, expectedPortConfig := range tc.expected {
195 195
 			assertContains(t, port.Value(), expectedPortConfig)
196 196
 		}
... ...
@@ -241,7 +242,7 @@ func TestPortOptInvalidComplexSyntax(t *testing.T) {
241 241
 	}
242 242
 	for _, tc := range testCases {
243 243
 		var port PortOpt
244
-		assert.Error(t, port.Set(tc.value), tc.expectedError)
244
+		testutil.ErrorContains(t, port.Set(tc.value), tc.expectedError)
245 245
 	}
246 246
 }
247 247
 
... ...
@@ -268,16 +269,16 @@ func TestPortOptInvalidSimpleSyntax(t *testing.T) {
268 268
 		},
269 269
 		{
270 270
 			value:         "",
271
-			expectedError: "No port specified",
271
+			expectedError: "No port specified: <empty>",
272 272
 		},
273 273
 		{
274 274
 			value:         "1.1.1.1:80:80",
275
-			expectedError: "HostIP is not supported",
275
+			expectedError: "HostIP is not supported.",
276 276
 		},
277 277
 	}
278 278
 	for _, tc := range testCases {
279 279
 		var port PortOpt
280
-		assert.Error(t, port.Set(tc.value), tc.expectedError)
280
+		assert.EqualError(t, port.Set(tc.value), tc.expectedError)
281 281
 	}
282 282
 }
283 283
 
... ...
@@ -1,28 +1,29 @@
1 1
 package opts
2 2
 
3 3
 import (
4
-	"github.com/docker/docker/pkg/testutil/assert"
5 4
 	"testing"
5
+
6
+	"github.com/stretchr/testify/assert"
6 7
 )
7 8
 
8 9
 func TestQuotedStringSetWithQuotes(t *testing.T) {
9 10
 	value := ""
10 11
 	qs := NewQuotedString(&value)
11
-	assert.NilError(t, qs.Set("\"something\""))
12
-	assert.Equal(t, qs.String(), "something")
13
-	assert.Equal(t, value, "something")
12
+	assert.NoError(t, qs.Set(`"something"`))
13
+	assert.Equal(t, "something", qs.String())
14
+	assert.Equal(t, "something", value)
14 15
 }
15 16
 
16 17
 func TestQuotedStringSetWithMismatchedQuotes(t *testing.T) {
17 18
 	value := ""
18 19
 	qs := NewQuotedString(&value)
19
-	assert.NilError(t, qs.Set("\"something'"))
20
-	assert.Equal(t, qs.String(), "\"something'")
20
+	assert.NoError(t, qs.Set(`"something'`))
21
+	assert.Equal(t, `"something'`, qs.String())
21 22
 }
22 23
 
23 24
 func TestQuotedStringSetWithNoQuotes(t *testing.T) {
24 25
 	value := ""
25 26
 	qs := NewQuotedString(&value)
26
-	assert.NilError(t, qs.Set("something"))
27
-	assert.Equal(t, qs.String(), "something")
27
+	assert.NoError(t, qs.Set("something"))
28
+	assert.Equal(t, "something", qs.String())
28 29
 }
... ...
@@ -4,76 +4,77 @@ import (
4 4
 	"os"
5 5
 	"testing"
6 6
 
7
-	"github.com/docker/docker/pkg/testutil/assert"
7
+	"github.com/stretchr/testify/assert"
8
+	"github.com/stretchr/testify/require"
8 9
 )
9 10
 
10 11
 func TestSecretOptionsSimple(t *testing.T) {
11 12
 	var opt SecretOpt
12 13
 
13 14
 	testCase := "app-secret"
14
-	assert.NilError(t, opt.Set(testCase))
15
+	assert.NoError(t, opt.Set(testCase))
15 16
 
16 17
 	reqs := opt.Value()
17
-	assert.Equal(t, len(reqs), 1)
18
+	require.Len(t, reqs, 1)
18 19
 	req := reqs[0]
19
-	assert.Equal(t, req.SecretName, "app-secret")
20
-	assert.Equal(t, req.File.Name, "app-secret")
21
-	assert.Equal(t, req.File.UID, "0")
22
-	assert.Equal(t, req.File.GID, "0")
20
+	assert.Equal(t, "app-secret", req.SecretName)
21
+	assert.Equal(t, "app-secret", req.File.Name)
22
+	assert.Equal(t, "0", req.File.UID)
23
+	assert.Equal(t, "0", req.File.GID)
23 24
 }
24 25
 
25 26
 func TestSecretOptionsSourceTarget(t *testing.T) {
26 27
 	var opt SecretOpt
27 28
 
28 29
 	testCase := "source=foo,target=testing"
29
-	assert.NilError(t, opt.Set(testCase))
30
+	assert.NoError(t, opt.Set(testCase))
30 31
 
31 32
 	reqs := opt.Value()
32
-	assert.Equal(t, len(reqs), 1)
33
+	require.Len(t, reqs, 1)
33 34
 	req := reqs[0]
34
-	assert.Equal(t, req.SecretName, "foo")
35
-	assert.Equal(t, req.File.Name, "testing")
35
+	assert.Equal(t, "foo", req.SecretName)
36
+	assert.Equal(t, "testing", req.File.Name)
36 37
 }
37 38
 
38 39
 func TestSecretOptionsShorthand(t *testing.T) {
39 40
 	var opt SecretOpt
40 41
 
41 42
 	testCase := "src=foo,target=testing"
42
-	assert.NilError(t, opt.Set(testCase))
43
+	assert.NoError(t, opt.Set(testCase))
43 44
 
44 45
 	reqs := opt.Value()
45
-	assert.Equal(t, len(reqs), 1)
46
+	require.Len(t, reqs, 1)
46 47
 	req := reqs[0]
47
-	assert.Equal(t, req.SecretName, "foo")
48
+	assert.Equal(t, "foo", req.SecretName)
48 49
 }
49 50
 
50 51
 func TestSecretOptionsCustomUidGid(t *testing.T) {
51 52
 	var opt SecretOpt
52 53
 
53 54
 	testCase := "source=foo,target=testing,uid=1000,gid=1001"
54
-	assert.NilError(t, opt.Set(testCase))
55
+	assert.NoError(t, opt.Set(testCase))
55 56
 
56 57
 	reqs := opt.Value()
57
-	assert.Equal(t, len(reqs), 1)
58
+	require.Len(t, reqs, 1)
58 59
 	req := reqs[0]
59
-	assert.Equal(t, req.SecretName, "foo")
60
-	assert.Equal(t, req.File.Name, "testing")
61
-	assert.Equal(t, req.File.UID, "1000")
62
-	assert.Equal(t, req.File.GID, "1001")
60
+	assert.Equal(t, "foo", req.SecretName)
61
+	assert.Equal(t, "testing", req.File.Name)
62
+	assert.Equal(t, "1000", req.File.UID)
63
+	assert.Equal(t, "1001", req.File.GID)
63 64
 }
64 65
 
65 66
 func TestSecretOptionsCustomMode(t *testing.T) {
66 67
 	var opt SecretOpt
67 68
 
68 69
 	testCase := "source=foo,target=testing,uid=1000,gid=1001,mode=0444"
69
-	assert.NilError(t, opt.Set(testCase))
70
+	assert.NoError(t, opt.Set(testCase))
70 71
 
71 72
 	reqs := opt.Value()
72
-	assert.Equal(t, len(reqs), 1)
73
+	require.Len(t, reqs, 1)
73 74
 	req := reqs[0]
74
-	assert.Equal(t, req.SecretName, "foo")
75
-	assert.Equal(t, req.File.Name, "testing")
76
-	assert.Equal(t, req.File.UID, "1000")
77
-	assert.Equal(t, req.File.GID, "1001")
78
-	assert.Equal(t, req.File.Mode, os.FileMode(0444))
75
+	assert.Equal(t, "foo", req.SecretName)
76
+	assert.Equal(t, "testing", req.File.Name)
77
+	assert.Equal(t, "1000", req.File.UID)
78
+	assert.Equal(t, "1001", req.File.GID)
79
+	assert.Equal(t, os.FileMode(0444), req.File.Mode)
79 80
 }
... ...
@@ -14,7 +14,8 @@ import (
14 14
 	"testing"
15 15
 	"time"
16 16
 
17
-	"github.com/docker/docker/pkg/testutil/assert"
17
+	"github.com/stretchr/testify/assert"
18
+	"github.com/stretchr/testify/require"
18 19
 )
19 20
 
20 21
 var tmp string
... ...
@@ -1211,19 +1212,19 @@ func TestReplaceFileTarWrapper(t *testing.T) {
1211 1211
 			map[string]TarModifierFunc{testcase.filename: testcase.modifier})
1212 1212
 
1213 1213
 		actual := readFileFromArchive(t, resultArchive, testcase.filename, testcase.fileCount, testcase.doc)
1214
-		assert.Equal(t, actual, testcase.expected, testcase.doc)
1214
+		assert.Equal(t, testcase.expected, actual, testcase.doc)
1215 1215
 	}
1216 1216
 }
1217 1217
 
1218 1218
 func buildSourceArchive(t *testing.T, numberOfFiles int) (io.ReadCloser, func()) {
1219 1219
 	srcDir, err := ioutil.TempDir("", "docker-test-srcDir")
1220
-	assert.NilError(t, err)
1220
+	require.NoError(t, err)
1221 1221
 
1222 1222
 	_, err = prepareUntarSourceDirectory(numberOfFiles, srcDir, false)
1223
-	assert.NilError(t, err)
1223
+	require.NoError(t, err)
1224 1224
 
1225 1225
 	sourceArchive, err := TarWithOptions(srcDir, &TarOptions{})
1226
-	assert.NilError(t, err)
1226
+	require.NoError(t, err)
1227 1227
 	return sourceArchive, func() {
1228 1228
 		os.RemoveAll(srcDir)
1229 1229
 		sourceArchive.Close()
... ...
@@ -1257,16 +1258,16 @@ func appendModifier(path string, header *tar.Header, content io.Reader) (*tar.He
1257 1257
 
1258 1258
 func readFileFromArchive(t *testing.T, archive io.ReadCloser, name string, expectedCount int, doc string) string {
1259 1259
 	destDir, err := ioutil.TempDir("", "docker-test-destDir")
1260
-	assert.NilError(t, err)
1260
+	require.NoError(t, err)
1261 1261
 	defer os.RemoveAll(destDir)
1262 1262
 
1263 1263
 	err = Untar(archive, destDir, nil)
1264
-	assert.NilError(t, err)
1264
+	require.NoError(t, err)
1265 1265
 
1266 1266
 	files, _ := ioutil.ReadDir(destDir)
1267
-	assert.Equal(t, len(files), expectedCount, doc)
1267
+	assert.Len(t, files, expectedCount, doc)
1268 1268
 
1269 1269
 	content, err := ioutil.ReadFile(filepath.Join(destDir, name))
1270
-	assert.NilError(t, err)
1270
+	assert.NoError(t, err)
1271 1271
 	return string(content)
1272 1272
 }
... ...
@@ -4,27 +4,27 @@ import (
4 4
 	"bytes"
5 5
 	"testing"
6 6
 
7
-	"github.com/docker/docker/pkg/testutil/assert"
7
+	"github.com/stretchr/testify/assert"
8 8
 )
9 9
 
10 10
 func TestParseStringFunctions(t *testing.T) {
11 11
 	tm, err := Parse(`{{join (split . ":") "/"}}`)
12
-	assert.NilError(t, err)
12
+	assert.NoError(t, err)
13 13
 
14 14
 	var b bytes.Buffer
15
-	assert.NilError(t, tm.Execute(&b, "text:with:colon"))
15
+	assert.NoError(t, tm.Execute(&b, "text:with:colon"))
16 16
 	want := "text/with/colon"
17
-	assert.Equal(t, b.String(), want)
17
+	assert.Equal(t, want, b.String())
18 18
 }
19 19
 
20 20
 func TestNewParse(t *testing.T) {
21 21
 	tm, err := NewParse("foo", "this is a {{ . }}")
22
-	assert.NilError(t, err)
22
+	assert.NoError(t, err)
23 23
 
24 24
 	var b bytes.Buffer
25
-	assert.NilError(t, tm.Execute(&b, "string"))
25
+	assert.NoError(t, tm.Execute(&b, "string"))
26 26
 	want := "this is a string"
27
-	assert.Equal(t, b.String(), want)
27
+	assert.Equal(t, want, b.String())
28 28
 }
29 29
 
30 30
 func TestParseTruncateFunction(t *testing.T) {
... ...
@@ -50,10 +50,10 @@ func TestParseTruncateFunction(t *testing.T) {
50 50
 
51 51
 	for _, testCase := range testCases {
52 52
 		tm, err := Parse(testCase.template)
53
-		assert.NilError(t, err)
53
+		assert.NoError(t, err)
54 54
 
55 55
 		var b bytes.Buffer
56
-		assert.NilError(t, tm.Execute(&b, source))
57
-		assert.Equal(t, b.String(), testCase.expected)
56
+		assert.NoError(t, tm.Execute(&b, source))
57
+		assert.Equal(t, testCase.expected, b.String())
58 58
 	}
59 59
 }
60 60
deleted file mode 100644
... ...
@@ -1,132 +0,0 @@
1
-// Package assert contains functions for making assertions in unit tests
2
-package assert
3
-
4
-import (
5
-	"fmt"
6
-	"path/filepath"
7
-	"reflect"
8
-	"runtime"
9
-	"strings"
10
-	"unicode"
11
-
12
-	"github.com/davecgh/go-spew/spew"
13
-)
14
-
15
-// TestingT is an interface which defines the methods of testing.T that are
16
-// required by this package
17
-type TestingT interface {
18
-	Fatalf(string, ...interface{})
19
-}
20
-
21
-// Equal compare the actual value to the expected value and fails the test if
22
-// they are not equal.
23
-func Equal(t TestingT, actual, expected interface{}, extra ...string) {
24
-	if expected != actual {
25
-		fatalWithExtra(t, extra, "Expected '%v' (%T) got '%v' (%T)", expected, expected, actual, actual)
26
-	}
27
-}
28
-
29
-// EqualNormalizedString compare the actual value to the expected value after applying the specified
30
-// transform function. It fails the test if these two transformed string are not equal.
31
-// For example `EqualNormalizedString(t, RemoveSpace, "foo\n", "foo")` wouldn't fail the test as
32
-// spaces (and thus '\n') are removed before comparing the string.
33
-func EqualNormalizedString(t TestingT, transformFun func(rune) rune, actual, expected string) {
34
-	if strings.Map(transformFun, actual) != strings.Map(transformFun, expected) {
35
-		fatal(t, "Expected '%v' got '%v'", expected, expected, actual, actual)
36
-	}
37
-}
38
-
39
-// RemoveSpace returns -1 if the specified runes is considered as a space (unicode)
40
-// and the rune itself otherwise.
41
-func RemoveSpace(r rune) rune {
42
-	if unicode.IsSpace(r) {
43
-		return -1
44
-	}
45
-	return r
46
-}
47
-
48
-//EqualStringSlice compares two slices and fails the test if they do not contain
49
-// the same items.
50
-func EqualStringSlice(t TestingT, actual, expected []string) {
51
-	if len(actual) != len(expected) {
52
-		fatal(t, "Expected (length %d): %q\nActual (length %d): %q",
53
-			len(expected), expected, len(actual), actual)
54
-	}
55
-	for i, item := range actual {
56
-		if item != expected[i] {
57
-			fatal(t, "Slices differ at element %d, expected %q got %q",
58
-				i, expected[i], item)
59
-		}
60
-	}
61
-}
62
-
63
-// NilError asserts that the error is nil, otherwise it fails the test.
64
-func NilError(t TestingT, err error) {
65
-	if err != nil {
66
-		fatal(t, "Expected no error, got: %s", err.Error())
67
-	}
68
-}
69
-
70
-// DeepEqual compare the actual value to the expected value and fails the test if
71
-// they are not "deeply equal".
72
-func DeepEqual(t TestingT, actual, expected interface{}) {
73
-	if !reflect.DeepEqual(actual, expected) {
74
-		fatal(t, "Expected (%T):\n%v\n\ngot (%T):\n%s\n",
75
-			expected, spew.Sdump(expected), actual, spew.Sdump(actual))
76
-	}
77
-}
78
-
79
-// Error asserts that error is not nil, and contains the expected text,
80
-// otherwise it fails the test.
81
-func Error(t TestingT, err error, contains string) {
82
-	if err == nil {
83
-		fatal(t, "Expected an error, but error was nil")
84
-	}
85
-
86
-	if !strings.Contains(err.Error(), contains) {
87
-		fatal(t, "Expected error to contain '%s', got '%s'", contains, err.Error())
88
-	}
89
-}
90
-
91
-// Contains asserts that the string contains a substring, otherwise it fails the
92
-// test.
93
-func Contains(t TestingT, actual, contains string) {
94
-	if !strings.Contains(actual, contains) {
95
-		fatal(t, "Expected '%s' to contain '%s'", actual, contains)
96
-	}
97
-}
98
-
99
-// NotNil fails the test if the object is nil
100
-func NotNil(t TestingT, obj interface{}) {
101
-	if obj == nil {
102
-		fatal(t, "Expected non-nil value.")
103
-	}
104
-}
105
-
106
-// Nil fails the test if the object is not nil
107
-func Nil(t TestingT, obj interface{}) {
108
-	if obj != nil {
109
-		fatal(t, "Expected nil value, got (%T) %s", obj, obj)
110
-	}
111
-}
112
-
113
-func fatal(t TestingT, format string, args ...interface{}) {
114
-	t.Fatalf(errorSource()+format, args...)
115
-}
116
-
117
-func fatalWithExtra(t TestingT, extra []string, format string, args ...interface{}) {
118
-	msg := fmt.Sprintf(errorSource()+format, args...)
119
-	if len(extra) > 0 {
120
-		msg += ": " + strings.Join(extra, ", ")
121
-	}
122
-	t.Fatalf(msg)
123
-}
124
-
125
-// See testing.decorate()
126
-func errorSource() string {
127
-	_, filename, line, ok := runtime.Caller(3)
128
-	if !ok {
129
-		return ""
130
-	}
131
-	return fmt.Sprintf("%s:%d: ", filepath.Base(filename), line)
132
-}
... ...
@@ -6,7 +6,7 @@ import (
6 6
 	"testing"
7 7
 	"time"
8 8
 
9
-	"github.com/docker/docker/pkg/testutil/assert"
9
+	"github.com/stretchr/testify/assert"
10 10
 )
11 11
 
12 12
 func TestRunCommand(t *testing.T) {
... ...
@@ -74,7 +74,7 @@ func TestRunCommandWithTimeoutKilled(t *testing.T) {
74 74
 	result.Assert(t, Expected{Timeout: true})
75 75
 
76 76
 	ones := strings.Split(result.Stdout(), "\n")
77
-	assert.Equal(t, len(ones), 4)
77
+	assert.Len(t, ones, 4)
78 78
 }
79 79
 
80 80
 func TestRunCommandWithErrors(t *testing.T) {
81 81
new file mode 100644
... ...
@@ -0,0 +1,33 @@
0
+package testutil
1
+
2
+import (
3
+	"strings"
4
+	"unicode"
5
+
6
+	"github.com/stretchr/testify/assert"
7
+	"github.com/stretchr/testify/require"
8
+)
9
+
10
+// ErrorContains checks that the error is not nil, and contains the expected
11
+// substring.
12
+func ErrorContains(t require.TestingT, err error, expectedError string) {
13
+	require.Error(t, err)
14
+	assert.Contains(t, err.Error(), expectedError)
15
+}
16
+
17
+// EqualNormalizedString compare the actual value to the expected value after applying the specified
18
+// transform function. It fails the test if these two transformed string are not equal.
19
+// For example `EqualNormalizedString(t, RemoveSpace, "foo\n", "foo")` wouldn't fail the test as
20
+// spaces (and thus '\n') are removed before comparing the string.
21
+func EqualNormalizedString(t require.TestingT, transformFun func(rune) rune, actual, expected string) {
22
+	require.Equal(t, strings.Map(transformFun, expected), strings.Map(transformFun, actual))
23
+}
24
+
25
+// RemoveSpace returns -1 if the specified runes is considered as a space (unicode)
26
+// and the rune itself otherwise.
27
+func RemoveSpace(r rune) rune {
28
+	if unicode.IsSpace(r) {
29
+		return -1
30
+	}
31
+	return r
32
+}
... ...
@@ -1,9 +1,10 @@
1 1
 package tempfile
2 2
 
3 3
 import (
4
-	"github.com/docker/docker/pkg/testutil/assert"
5 4
 	"io/ioutil"
6 5
 	"os"
6
+
7
+	"github.com/stretchr/testify/require"
7 8
 )
8 9
 
9 10
 // TempFile is a temporary file that can be used with unit tests. TempFile
... ...
@@ -14,12 +15,12 @@ type TempFile struct {
14 14
 }
15 15
 
16 16
 // NewTempFile returns a new temp file with contents
17
-func NewTempFile(t assert.TestingT, prefix string, content string) *TempFile {
17
+func NewTempFile(t require.TestingT, prefix string, content string) *TempFile {
18 18
 	file, err := ioutil.TempFile("", prefix+"-")
19
-	assert.NilError(t, err)
19
+	require.NoError(t, err)
20 20
 
21 21
 	_, err = file.Write([]byte(content))
22
-	assert.NilError(t, err)
22
+	require.NoError(t, err)
23 23
 	file.Close()
24 24
 	return &TempFile{File: file}
25 25
 }
... ...
@@ -4,7 +4,7 @@ github.com/Microsoft/hcsshim v0.5.13
4 4
 # TODO: get rid of this fork once PR https://github.com/Microsoft/go-winio/pull/43 is merged
5 5
 github.com/Microsoft/go-winio 7c7d6b461cb10872c1138a0d7f3acf9a41b5c353 https://github.com/dgageot/go-winio.git
6 6
 github.com/Sirupsen/logrus v0.11.0
7
-github.com/davecgh/go-spew 6d212800a42e8ab5c146b8ace3490ee17e5225f9
7
+github.com/davecgh/go-spew 346938d642f2ec3594ed81d874461961cd0faa76
8 8
 github.com/docker/libtrust 9cbd2a1374f46905c68a4eb3694a130610adc62a
9 9
 github.com/go-check/check 4ed411733c5785b40214c70bce814c3a3a689609 https://github.com/cpuguy83/check.git
10 10
 github.com/gorilla/context v1.1
... ...
@@ -19,6 +19,7 @@ golang.org/x/sys 8f0908ab3b2457e2e15403d3697c9ef5cb4b57a9
19 19
 github.com/docker/go-units 9e638d38cf6977a37a8ea0078f3ee75a7cdb2dd1
20 20
 github.com/docker/go-connections e15c02316c12de00874640cd76311849de2aeed5
21 21
 golang.org/x/text f72d8390a633d5dfb0cc84043294db9f6c935756
22
+github.com/stretchr/testify 4d4bfba8f1d1027c4fdbe371823030df51419987
22 23
 
23 24
 github.com/RackSec/srslog 456df3a81436d29ba874f3590eeeee25d666f8a5
24 25
 github.com/imdario/mergo 0.2.1
... ...
@@ -1,6 +1,6 @@
1 1
 ISC License
2 2
 
3
-Copyright (c) 2012-2013 Dave Collins <dave@davec.name>
3
+Copyright (c) 2012-2016 Dave Collins <dave@davec.name>
4 4
 
5 5
 Permission to use, copy, modify, and distribute this software for any
6 6
 purpose with or without fee is hereby granted, provided that the above
... ...
@@ -1,11 +1,13 @@
1 1
 go-spew
2 2
 =======
3 3
 
4
-[![Build Status](https://travis-ci.org/davecgh/go-spew.png?branch=master)]
5
-(https://travis-ci.org/davecgh/go-spew) [![Coverage Status]
6
-(https://coveralls.io/repos/davecgh/go-spew/badge.png?branch=master)]
4
+[![Build Status](https://img.shields.io/travis/davecgh/go-spew.svg)]
5
+(https://travis-ci.org/davecgh/go-spew) [![ISC License]
6
+(http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) [![Coverage Status]
7
+(https://img.shields.io/coveralls/davecgh/go-spew.svg)]
7 8
 (https://coveralls.io/r/davecgh/go-spew?branch=master)
8 9
 
10
+
9 11
 Go-spew implements a deep pretty printer for Go data structures to aid in
10 12
 debugging.  A comprehensive suite of tests with 100% test coverage is provided
11 13
 to ensure proper functionality.  See `test_coverage.txt` for the gocov coverage
... ...
@@ -19,7 +21,7 @@ post about it
19 19
 
20 20
 ## Documentation
21 21
 
22
-[![GoDoc](https://godoc.org/github.com/davecgh/go-spew/spew?status.png)]
22
+[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)]
23 23
 (http://godoc.org/github.com/davecgh/go-spew/spew)
24 24
 
25 25
 Full `go doc` style documentation for the project can be viewed online without
... ...
@@ -160,6 +162,15 @@ options. See the ConfigState documentation for more details.
160 160
 	App Engine or with the "safe" build tag specified.
161 161
 	Pointer method invocation is enabled by default.
162 162
 
163
+* DisablePointerAddresses
164
+	DisablePointerAddresses specifies whether to disable the printing of
165
+	pointer addresses. This is useful when diffing data structures in tests.
166
+
167
+* DisableCapacities
168
+	DisableCapacities specifies whether to disable the printing of capacities
169
+	for arrays, slices, maps and channels. This is useful when diffing data
170
+	structures in tests.
171
+
163 172
 * ContinueOnMethod
164 173
 	Enables recursion into types after invoking error and Stringer interface
165 174
 	methods. Recursion after method invocation is disabled by default.
... ...
@@ -191,4 +202,4 @@ using the unsafe package.
191 191
 
192 192
 ## License
193 193
 
194
-Go-spew is licensed under the liberal ISC License.
194
+Go-spew is licensed under the [copyfree](http://copyfree.org) ISC License.
... ...
@@ -1,4 +1,4 @@
1
-// Copyright (c) 2015 Dave Collins <dave@davec.name>
1
+// Copyright (c) 2015-2016 Dave Collins <dave@davec.name>
2 2
 //
3 3
 // Permission to use, copy, modify, and distribute this software for any
4 4
 // purpose with or without fee is hereby granted, provided that the above
... ...
@@ -1,4 +1,4 @@
1
-// Copyright (c) 2015 Dave Collins <dave@davec.name>
1
+// Copyright (c) 2015-2016 Dave Collins <dave@davec.name>
2 2
 //
3 3
 // Permission to use, copy, modify, and distribute this software for any
4 4
 // purpose with or without fee is hereby granted, provided that the above
... ...
@@ -1,5 +1,5 @@
1 1
 /*
2
- * Copyright (c) 2013 Dave Collins <dave@davec.name>
2
+ * Copyright (c) 2013-2016 Dave Collins <dave@davec.name>
3 3
  *
4 4
  * Permission to use, copy, modify, and distribute this software for any
5 5
  * purpose with or without fee is hereby granted, provided that the above
... ...
@@ -1,5 +1,5 @@
1 1
 /*
2
- * Copyright (c) 2013 Dave Collins <dave@davec.name>
2
+ * Copyright (c) 2013-2016 Dave Collins <dave@davec.name>
3 3
  *
4 4
  * Permission to use, copy, modify, and distribute this software for any
5 5
  * purpose with or without fee is hereby granted, provided that the above
... ...
@@ -67,6 +67,15 @@ type ConfigState struct {
67 67
 	// Google App Engine or with the "safe" build tag specified.
68 68
 	DisablePointerMethods bool
69 69
 
70
+	// DisablePointerAddresses specifies whether to disable the printing of
71
+	// pointer addresses. This is useful when diffing data structures in tests.
72
+	DisablePointerAddresses bool
73
+
74
+	// DisableCapacities specifies whether to disable the printing of capacities
75
+	// for arrays, slices, maps and channels. This is useful when diffing
76
+	// data structures in tests.
77
+	DisableCapacities bool
78
+
70 79
 	// ContinueOnMethod specifies whether or not recursion should continue once
71 80
 	// a custom error or Stringer interface is invoked.  The default, false,
72 81
 	// means it will print the results of invoking the custom error or Stringer
... ...
@@ -1,5 +1,5 @@
1 1
 /*
2
- * Copyright (c) 2013 Dave Collins <dave@davec.name>
2
+ * Copyright (c) 2013-2016 Dave Collins <dave@davec.name>
3 3
  *
4 4
  * Permission to use, copy, modify, and distribute this software for any
5 5
  * purpose with or without fee is hereby granted, provided that the above
... ...
@@ -91,6 +91,15 @@ The following configuration options are available:
91 91
 		which only accept pointer receivers from non-pointer variables.
92 92
 		Pointer method invocation is enabled by default.
93 93
 
94
+	* DisablePointerAddresses
95
+		DisablePointerAddresses specifies whether to disable the printing of
96
+		pointer addresses. This is useful when diffing data structures in tests.
97
+
98
+	* DisableCapacities
99
+		DisableCapacities specifies whether to disable the printing of
100
+		capacities for arrays, slices, maps and channels. This is useful when
101
+		diffing data structures in tests.
102
+
94 103
 	* ContinueOnMethod
95 104
 		Enables recursion into types after invoking error and Stringer interface
96 105
 		methods. Recursion after method invocation is disabled by default.
... ...
@@ -1,5 +1,5 @@
1 1
 /*
2
- * Copyright (c) 2013 Dave Collins <dave@davec.name>
2
+ * Copyright (c) 2013-2016 Dave Collins <dave@davec.name>
3 3
  *
4 4
  * Permission to use, copy, modify, and distribute this software for any
5 5
  * purpose with or without fee is hereby granted, provided that the above
... ...
@@ -129,7 +129,7 @@ func (d *dumpState) dumpPtr(v reflect.Value) {
129 129
 	d.w.Write(closeParenBytes)
130 130
 
131 131
 	// Display pointer information.
132
-	if len(pointerChain) > 0 {
132
+	if !d.cs.DisablePointerAddresses && len(pointerChain) > 0 {
133 133
 		d.w.Write(openParenBytes)
134 134
 		for i, addr := range pointerChain {
135 135
 			if i > 0 {
... ...
@@ -282,13 +282,13 @@ func (d *dumpState) dump(v reflect.Value) {
282 282
 	case reflect.Map, reflect.String:
283 283
 		valueLen = v.Len()
284 284
 	}
285
-	if valueLen != 0 || valueCap != 0 {
285
+	if valueLen != 0 || !d.cs.DisableCapacities && valueCap != 0 {
286 286
 		d.w.Write(openParenBytes)
287 287
 		if valueLen != 0 {
288 288
 			d.w.Write(lenEqualsBytes)
289 289
 			printInt(d.w, int64(valueLen), 10)
290 290
 		}
291
-		if valueCap != 0 {
291
+		if !d.cs.DisableCapacities && valueCap != 0 {
292 292
 			if valueLen != 0 {
293 293
 				d.w.Write(spaceBytes)
294 294
 			}
... ...
@@ -1,5 +1,5 @@
1 1
 /*
2
- * Copyright (c) 2013 Dave Collins <dave@davec.name>
2
+ * Copyright (c) 2013-2016 Dave Collins <dave@davec.name>
3 3
  *
4 4
  * Permission to use, copy, modify, and distribute this software for any
5 5
  * purpose with or without fee is hereby granted, provided that the above
... ...
@@ -1,5 +1,5 @@
1 1
 /*
2
- * Copyright (c) 2013 Dave Collins <dave@davec.name>
2
+ * Copyright (c) 2013-2016 Dave Collins <dave@davec.name>
3 3
  *
4 4
  * Permission to use, copy, modify, and distribute this software for any
5 5
  * purpose with or without fee is hereby granted, provided that the above
6 6
new file mode 100644
... ...
@@ -0,0 +1,332 @@
0
+Testify - Thou Shalt Write Tests
1
+================================
2
+
3
+[![Build Status](https://travis-ci.org/stretchr/testify.svg)](https://travis-ci.org/stretchr/testify) [![Go Report Card](https://goreportcard.com/badge/github.com/stretchr/testify)](https://goreportcard.com/report/github.com/stretchr/testify) [![GoDoc](https://godoc.org/github.com/stretchr/testify?status.svg)](https://godoc.org/github.com/stretchr/testify)
4
+
5
+Go code (golang) set of packages that provide many tools for testifying that your code will behave as you intend.
6
+
7
+Features include:
8
+
9
+  * [Easy assertions](#assert-package)
10
+  * [Mocking](#mock-package)
11
+  * [HTTP response trapping](#http-package)
12
+  * [Testing suite interfaces and functions](#suite-package)
13
+
14
+Get started:
15
+
16
+  * Install testify with [one line of code](#installation), or [update it with another](#staying-up-to-date)
17
+  * For an introduction to writing test code in Go, see http://golang.org/doc/code.html#Testing
18
+  * Check out the API Documentation http://godoc.org/github.com/stretchr/testify
19
+  * To make your testing life easier, check out our other project, [gorc](http://github.com/stretchr/gorc)
20
+  * A little about [Test-Driven Development (TDD)](http://en.wikipedia.org/wiki/Test-driven_development)
21
+
22
+
23
+
24
+[`assert`](http://godoc.org/github.com/stretchr/testify/assert "API documentation") package
25
+-------------------------------------------------------------------------------------------
26
+
27
+The `assert` package provides some helpful methods that allow you to write better test code in Go.
28
+
29
+  * Prints friendly, easy to read failure descriptions
30
+  * Allows for very readable code
31
+  * Optionally annotate each assertion with a message
32
+
33
+See it in action:
34
+
35
+```go
36
+package yours
37
+
38
+import (
39
+  "testing"
40
+  "github.com/stretchr/testify/assert"
41
+)
42
+
43
+func TestSomething(t *testing.T) {
44
+
45
+  // assert equality
46
+  assert.Equal(t, 123, 123, "they should be equal")
47
+
48
+  // assert inequality
49
+  assert.NotEqual(t, 123, 456, "they should not be equal")
50
+
51
+  // assert for nil (good for errors)
52
+  assert.Nil(t, object)
53
+
54
+  // assert for not nil (good when you expect something)
55
+  if assert.NotNil(t, object) {
56
+
57
+    // now we know that object isn't nil, we are safe to make
58
+    // further assertions without causing any errors
59
+    assert.Equal(t, "Something", object.Value)
60
+
61
+  }
62
+
63
+}
64
+```
65
+
66
+  * Every assert func takes the `testing.T` object as the first argument.  This is how it writes the errors out through the normal `go test` capabilities.
67
+  * Every assert func returns a bool indicating whether the assertion was successful or not, this is useful for if you want to go on making further assertions under certain conditions.
68
+
69
+if you assert many times, use the below:
70
+
71
+```go
72
+package yours
73
+
74
+import (
75
+  "testing"
76
+  "github.com/stretchr/testify/assert"
77
+)
78
+
79
+func TestSomething(t *testing.T) {
80
+  assert := assert.New(t)
81
+
82
+  // assert equality
83
+  assert.Equal(123, 123, "they should be equal")
84
+
85
+  // assert inequality
86
+  assert.NotEqual(123, 456, "they should not be equal")
87
+
88
+  // assert for nil (good for errors)
89
+  assert.Nil(object)
90
+
91
+  // assert for not nil (good when you expect something)
92
+  if assert.NotNil(object) {
93
+
94
+    // now we know that object isn't nil, we are safe to make
95
+    // further assertions without causing any errors
96
+    assert.Equal("Something", object.Value)
97
+  }
98
+}
99
+```
100
+
101
+[`require`](http://godoc.org/github.com/stretchr/testify/require "API documentation") package
102
+---------------------------------------------------------------------------------------------
103
+
104
+The `require` package provides same global functions as the `assert` package, but instead of returning a boolean result they terminate current test.
105
+
106
+See [t.FailNow](http://golang.org/pkg/testing/#T.FailNow) for details.
107
+
108
+
109
+[`http`](http://godoc.org/github.com/stretchr/testify/http "API documentation") package
110
+---------------------------------------------------------------------------------------
111
+
112
+The `http` package contains test objects useful for testing code that relies on the `net/http` package.  Check out the [(deprecated) API documentation for the `http` package](http://godoc.org/github.com/stretchr/testify/http).
113
+
114
+We recommend you use [httptest](http://golang.org/pkg/net/http/httptest) instead.
115
+
116
+[`mock`](http://godoc.org/github.com/stretchr/testify/mock "API documentation") package
117
+----------------------------------------------------------------------------------------
118
+
119
+The `mock` package provides a mechanism for easily writing mock objects that can be used in place of real objects when writing test code.
120
+
121
+An example test function that tests a piece of code that relies on an external object `testObj`, can setup expectations (testify) and assert that they indeed happened:
122
+
123
+```go
124
+package yours
125
+
126
+import (
127
+  "testing"
128
+  "github.com/stretchr/testify/mock"
129
+)
130
+
131
+/*
132
+  Test objects
133
+*/
134
+
135
+// MyMockedObject is a mocked object that implements an interface
136
+// that describes an object that the code I am testing relies on.
137
+type MyMockedObject struct{
138
+  mock.Mock
139
+}
140
+
141
+// DoSomething is a method on MyMockedObject that implements some interface
142
+// and just records the activity, and returns what the Mock object tells it to.
143
+//
144
+// In the real object, this method would do something useful, but since this
145
+// is a mocked object - we're just going to stub it out.
146
+//
147
+// NOTE: This method is not being tested here, code that uses this object is.
148
+func (m *MyMockedObject) DoSomething(number int) (bool, error) {
149
+
150
+  args := m.Called(number)
151
+  return args.Bool(0), args.Error(1)
152
+
153
+}
154
+
155
+/*
156
+  Actual test functions
157
+*/
158
+
159
+// TestSomething is an example of how to use our test object to
160
+// make assertions about some target code we are testing.
161
+func TestSomething(t *testing.T) {
162
+
163
+  // create an instance of our test object
164
+  testObj := new(MyMockedObject)
165
+
166
+  // setup expectations
167
+  testObj.On("DoSomething", 123).Return(true, nil)
168
+
169
+  // call the code we are testing
170
+  targetFuncThatDoesSomethingWithObj(testObj)
171
+
172
+  // assert that the expectations were met
173
+  testObj.AssertExpectations(t)
174
+
175
+}
176
+```
177
+
178
+For more information on how to write mock code, check out the [API documentation for the `mock` package](http://godoc.org/github.com/stretchr/testify/mock).
179
+
180
+You can use the [mockery tool](http://github.com/vektra/mockery) to autogenerate the mock code against an interface as well, making using mocks much quicker.
181
+
182
+[`suite`](http://godoc.org/github.com/stretchr/testify/suite "API documentation") package
183
+-----------------------------------------------------------------------------------------
184
+
185
+The `suite` package provides functionality that you might be used to from more common object oriented languages.  With it, you can build a testing suite as a struct, build setup/teardown methods and testing methods on your struct, and run them with 'go test' as per normal.
186
+
187
+An example suite is shown below:
188
+
189
+```go
190
+// Basic imports
191
+import (
192
+    "testing"
193
+    "github.com/stretchr/testify/assert"
194
+    "github.com/stretchr/testify/suite"
195
+)
196
+
197
+// Define the suite, and absorb the built-in basic suite
198
+// functionality from testify - including a T() method which
199
+// returns the current testing context
200
+type ExampleTestSuite struct {
201
+    suite.Suite
202
+    VariableThatShouldStartAtFive int
203
+}
204
+
205
+// Make sure that VariableThatShouldStartAtFive is set to five
206
+// before each test
207
+func (suite *ExampleTestSuite) SetupTest() {
208
+    suite.VariableThatShouldStartAtFive = 5
209
+}
210
+
211
+// All methods that begin with "Test" are run as tests within a
212
+// suite.
213
+func (suite *ExampleTestSuite) TestExample() {
214
+    assert.Equal(suite.T(), 5, suite.VariableThatShouldStartAtFive)
215
+}
216
+
217
+// In order for 'go test' to run this suite, we need to create
218
+// a normal test function and pass our suite to suite.Run
219
+func TestExampleTestSuite(t *testing.T) {
220
+    suite.Run(t, new(ExampleTestSuite))
221
+}
222
+```
223
+
224
+For a more complete example, using all of the functionality provided by the suite package, look at our [example testing suite](https://github.com/stretchr/testify/blob/master/suite/suite_test.go)
225
+
226
+For more information on writing suites, check out the [API documentation for the `suite` package](http://godoc.org/github.com/stretchr/testify/suite).
227
+
228
+`Suite` object has assertion methods:
229
+
230
+```go
231
+// Basic imports
232
+import (
233
+    "testing"
234
+    "github.com/stretchr/testify/suite"
235
+)
236
+
237
+// Define the suite, and absorb the built-in basic suite
238
+// functionality from testify - including assertion methods.
239
+type ExampleTestSuite struct {
240
+    suite.Suite
241
+    VariableThatShouldStartAtFive int
242
+}
243
+
244
+// Make sure that VariableThatShouldStartAtFive is set to five
245
+// before each test
246
+func (suite *ExampleTestSuite) SetupTest() {
247
+    suite.VariableThatShouldStartAtFive = 5
248
+}
249
+
250
+// All methods that begin with "Test" are run as tests within a
251
+// suite.
252
+func (suite *ExampleTestSuite) TestExample() {
253
+    suite.Equal(suite.VariableThatShouldStartAtFive, 5)
254
+}
255
+
256
+// In order for 'go test' to run this suite, we need to create
257
+// a normal test function and pass our suite to suite.Run
258
+func TestExampleTestSuite(t *testing.T) {
259
+    suite.Run(t, new(ExampleTestSuite))
260
+}
261
+```
262
+
263
+------
264
+
265
+Installation
266
+============
267
+
268
+To install Testify, use `go get`:
269
+
270
+    * Latest version: go get github.com/stretchr/testify
271
+    * Specific version: go get gopkg.in/stretchr/testify.v1
272
+
273
+This will then make the following packages available to you:
274
+
275
+    github.com/stretchr/testify/assert
276
+    github.com/stretchr/testify/mock
277
+    github.com/stretchr/testify/http
278
+
279
+Import the `testify/assert` package into your code using this template:
280
+
281
+```go
282
+package yours
283
+
284
+import (
285
+  "testing"
286
+  "github.com/stretchr/testify/assert"
287
+)
288
+
289
+func TestSomething(t *testing.T) {
290
+
291
+  assert.True(t, true, "True is true!")
292
+
293
+}
294
+```
295
+
296
+------
297
+
298
+Staying up to date
299
+==================
300
+
301
+To update Testify to the latest version, use `go get -u github.com/stretchr/testify`.
302
+
303
+------
304
+
305
+Version History
306
+===============
307
+
308
+   * 1.0 - New package versioning strategy adopted.
309
+
310
+------
311
+
312
+Contributing
313
+============
314
+
315
+Please feel free to submit issues, fork the repository and send pull requests!
316
+
317
+When submitting an issue, we ask that you please include a complete test function that demonstrates the issue.  Extra credit for those using Testify to write the test code that demonstrates it.
318
+
319
+------
320
+
321
+Licence
322
+=======
323
+Copyright (c) 2012 - 2013 Mat Ryer and Tyler Bunnell
324
+
325
+Please consider promoting this project if you find it useful.
326
+
327
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
328
+
329
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
330
+
331
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
... ...
@@ -1,386 +1,351 @@
1 1
 /*
2 2
 * CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen
3 3
 * THIS FILE MUST NOT BE EDITED BY HAND
4
-*/
4
+ */
5 5
 
6 6
 package assert
7 7
 
8 8
 import (
9
-
10 9
 	http "net/http"
11 10
 	url "net/url"
12 11
 	time "time"
13 12
 )
14 13
 
15
-
16 14
 // Condition uses a Comparison to assert a complex condition.
17 15
 func (a *Assertions) Condition(comp Comparison, msgAndArgs ...interface{}) bool {
18 16
 	return Condition(a.t, comp, msgAndArgs...)
19 17
 }
20 18
 
21
-
22 19
 // Contains asserts that the specified string, list(array, slice...) or map contains the
23 20
 // specified substring or element.
24
-// 
21
+//
25 22
 //    a.Contains("Hello World", "World", "But 'Hello World' does contain 'World'")
26 23
 //    a.Contains(["Hello", "World"], "World", "But ["Hello", "World"] does contain 'World'")
27 24
 //    a.Contains({"Hello": "World"}, "Hello", "But {'Hello': 'World'} does contain 'Hello'")
28
-// 
25
+//
29 26
 // Returns whether the assertion was successful (true) or not (false).
30 27
 func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool {
31 28
 	return Contains(a.t, s, contains, msgAndArgs...)
32 29
 }
33 30
 
34
-
35 31
 // Empty asserts that the specified object is empty.  I.e. nil, "", false, 0 or either
36 32
 // a slice or a channel with len == 0.
37
-// 
33
+//
38 34
 //  a.Empty(obj)
39
-// 
35
+//
40 36
 // Returns whether the assertion was successful (true) or not (false).
41 37
 func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) bool {
42 38
 	return Empty(a.t, object, msgAndArgs...)
43 39
 }
44 40
 
45
-
46 41
 // Equal asserts that two objects are equal.
47
-// 
42
+//
48 43
 //    a.Equal(123, 123, "123 and 123 should be equal")
49
-// 
44
+//
50 45
 // Returns whether the assertion was successful (true) or not (false).
46
+//
47
+// Pointer variable equality is determined based on the equality of the
48
+// referenced values (as opposed to the memory addresses).
51 49
 func (a *Assertions) Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
52 50
 	return Equal(a.t, expected, actual, msgAndArgs...)
53 51
 }
54 52
 
55
-
56 53
 // EqualError asserts that a function returned an error (i.e. not `nil`)
57 54
 // and that it is equal to the provided error.
58
-// 
55
+//
59 56
 //   actualObj, err := SomeFunction()
60
-//   if assert.Error(t, err, "An error was expected") {
61
-// 	   assert.Equal(t, err, expectedError)
62
-//   }
63
-// 
57
+//   a.EqualError(err,  expectedErrorString, "An error was expected")
58
+//
64 59
 // Returns whether the assertion was successful (true) or not (false).
65 60
 func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ...interface{}) bool {
66 61
 	return EqualError(a.t, theError, errString, msgAndArgs...)
67 62
 }
68 63
 
69
-
70 64
 // EqualValues asserts that two objects are equal or convertable to the same types
71 65
 // and equal.
72
-// 
66
+//
73 67
 //    a.EqualValues(uint32(123), int32(123), "123 and 123 should be equal")
74
-// 
68
+//
75 69
 // Returns whether the assertion was successful (true) or not (false).
76 70
 func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
77 71
 	return EqualValues(a.t, expected, actual, msgAndArgs...)
78 72
 }
79 73
 
80
-
81 74
 // Error asserts that a function returned an error (i.e. not `nil`).
82
-// 
75
+//
83 76
 //   actualObj, err := SomeFunction()
84 77
 //   if a.Error(err, "An error was expected") {
85 78
 // 	   assert.Equal(t, err, expectedError)
86 79
 //   }
87
-// 
80
+//
88 81
 // Returns whether the assertion was successful (true) or not (false).
89 82
 func (a *Assertions) Error(err error, msgAndArgs ...interface{}) bool {
90 83
 	return Error(a.t, err, msgAndArgs...)
91 84
 }
92 85
 
93
-
94 86
 // Exactly asserts that two objects are equal is value and type.
95
-// 
87
+//
96 88
 //    a.Exactly(int32(123), int64(123), "123 and 123 should NOT be equal")
97
-// 
89
+//
98 90
 // Returns whether the assertion was successful (true) or not (false).
99 91
 func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
100 92
 	return Exactly(a.t, expected, actual, msgAndArgs...)
101 93
 }
102 94
 
103
-
104 95
 // Fail reports a failure through
105 96
 func (a *Assertions) Fail(failureMessage string, msgAndArgs ...interface{}) bool {
106 97
 	return Fail(a.t, failureMessage, msgAndArgs...)
107 98
 }
108 99
 
109
-
110 100
 // FailNow fails test
111 101
 func (a *Assertions) FailNow(failureMessage string, msgAndArgs ...interface{}) bool {
112 102
 	return FailNow(a.t, failureMessage, msgAndArgs...)
113 103
 }
114 104
 
115
-
116 105
 // False asserts that the specified value is false.
117
-// 
106
+//
118 107
 //    a.False(myBool, "myBool should be false")
119
-// 
108
+//
120 109
 // Returns whether the assertion was successful (true) or not (false).
121 110
 func (a *Assertions) False(value bool, msgAndArgs ...interface{}) bool {
122 111
 	return False(a.t, value, msgAndArgs...)
123 112
 }
124 113
 
125
-
126 114
 // HTTPBodyContains asserts that a specified handler returns a
127 115
 // body that contains a string.
128
-// 
116
+//
129 117
 //  a.HTTPBodyContains(myHandler, "www.google.com", nil, "I'm Feeling Lucky")
130
-// 
118
+//
131 119
 // Returns whether the assertion was successful (true) or not (false).
132 120
 func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) bool {
133 121
 	return HTTPBodyContains(a.t, handler, method, url, values, str)
134 122
 }
135 123
 
136
-
137 124
 // HTTPBodyNotContains asserts that a specified handler returns a
138 125
 // body that does not contain a string.
139
-// 
126
+//
140 127
 //  a.HTTPBodyNotContains(myHandler, "www.google.com", nil, "I'm Feeling Lucky")
141
-// 
128
+//
142 129
 // Returns whether the assertion was successful (true) or not (false).
143 130
 func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) bool {
144 131
 	return HTTPBodyNotContains(a.t, handler, method, url, values, str)
145 132
 }
146 133
 
147
-
148 134
 // HTTPError asserts that a specified handler returns an error status code.
149
-// 
135
+//
150 136
 //  a.HTTPError(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
151
-// 
137
+//
152 138
 // Returns whether the assertion was successful (true) or not (false).
153 139
 func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values) bool {
154 140
 	return HTTPError(a.t, handler, method, url, values)
155 141
 }
156 142
 
157
-
158 143
 // HTTPRedirect asserts that a specified handler returns a redirect status code.
159
-// 
144
+//
160 145
 //  a.HTTPRedirect(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
161
-// 
146
+//
162 147
 // Returns whether the assertion was successful (true) or not (false).
163 148
 func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values) bool {
164 149
 	return HTTPRedirect(a.t, handler, method, url, values)
165 150
 }
166 151
 
167
-
168 152
 // HTTPSuccess asserts that a specified handler returns a success status code.
169
-// 
153
+//
170 154
 //  a.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil)
171
-// 
155
+//
172 156
 // Returns whether the assertion was successful (true) or not (false).
173 157
 func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values) bool {
174 158
 	return HTTPSuccess(a.t, handler, method, url, values)
175 159
 }
176 160
 
177
-
178 161
 // Implements asserts that an object is implemented by the specified interface.
179
-// 
162
+//
180 163
 //    a.Implements((*MyInterface)(nil), new(MyObject), "MyObject")
181 164
 func (a *Assertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool {
182 165
 	return Implements(a.t, interfaceObject, object, msgAndArgs...)
183 166
 }
184 167
 
185
-
186 168
 // InDelta asserts that the two numerals are within delta of each other.
187
-// 
169
+//
188 170
 // 	 a.InDelta(math.Pi, (22 / 7.0), 0.01)
189
-// 
171
+//
190 172
 // Returns whether the assertion was successful (true) or not (false).
191 173
 func (a *Assertions) InDelta(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool {
192 174
 	return InDelta(a.t, expected, actual, delta, msgAndArgs...)
193 175
 }
194 176
 
195
-
196 177
 // InDeltaSlice is the same as InDelta, except it compares two slices.
197 178
 func (a *Assertions) InDeltaSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool {
198 179
 	return InDeltaSlice(a.t, expected, actual, delta, msgAndArgs...)
199 180
 }
200 181
 
201
-
202 182
 // InEpsilon asserts that expected and actual have a relative error less than epsilon
203
-// 
183
+//
204 184
 // Returns whether the assertion was successful (true) or not (false).
205 185
 func (a *Assertions) InEpsilon(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool {
206 186
 	return InEpsilon(a.t, expected, actual, epsilon, msgAndArgs...)
207 187
 }
208 188
 
209
-
210
-// InEpsilonSlice is the same as InEpsilon, except it compares two slices.
211
-func (a *Assertions) InEpsilonSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool {
212
-	return InEpsilonSlice(a.t, expected, actual, delta, msgAndArgs...)
189
+// InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices.
190
+func (a *Assertions) InEpsilonSlice(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool {
191
+	return InEpsilonSlice(a.t, expected, actual, epsilon, msgAndArgs...)
213 192
 }
214 193
 
215
-
216 194
 // IsType asserts that the specified objects are of the same type.
217 195
 func (a *Assertions) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) bool {
218 196
 	return IsType(a.t, expectedType, object, msgAndArgs...)
219 197
 }
220 198
 
221
-
222 199
 // JSONEq asserts that two JSON strings are equivalent.
223
-// 
200
+//
224 201
 //  a.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
225
-// 
202
+//
226 203
 // Returns whether the assertion was successful (true) or not (false).
227 204
 func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interface{}) bool {
228 205
 	return JSONEq(a.t, expected, actual, msgAndArgs...)
229 206
 }
230 207
 
231
-
232 208
 // Len asserts that the specified object has specific length.
233 209
 // Len also fails if the object has a type that len() not accept.
234
-// 
210
+//
235 211
 //    a.Len(mySlice, 3, "The size of slice is not 3")
236
-// 
212
+//
237 213
 // Returns whether the assertion was successful (true) or not (false).
238 214
 func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface{}) bool {
239 215
 	return Len(a.t, object, length, msgAndArgs...)
240 216
 }
241 217
 
242
-
243 218
 // Nil asserts that the specified object is nil.
244
-// 
219
+//
245 220
 //    a.Nil(err, "err should be nothing")
246
-// 
221
+//
247 222
 // Returns whether the assertion was successful (true) or not (false).
248 223
 func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) bool {
249 224
 	return Nil(a.t, object, msgAndArgs...)
250 225
 }
251 226
 
252
-
253 227
 // NoError asserts that a function returned no error (i.e. `nil`).
254
-// 
228
+//
255 229
 //   actualObj, err := SomeFunction()
256 230
 //   if a.NoError(err) {
257 231
 // 	   assert.Equal(t, actualObj, expectedObj)
258 232
 //   }
259
-// 
233
+//
260 234
 // Returns whether the assertion was successful (true) or not (false).
261 235
 func (a *Assertions) NoError(err error, msgAndArgs ...interface{}) bool {
262 236
 	return NoError(a.t, err, msgAndArgs...)
263 237
 }
264 238
 
265
-
266 239
 // NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
267 240
 // specified substring or element.
268
-// 
241
+//
269 242
 //    a.NotContains("Hello World", "Earth", "But 'Hello World' does NOT contain 'Earth'")
270 243
 //    a.NotContains(["Hello", "World"], "Earth", "But ['Hello', 'World'] does NOT contain 'Earth'")
271 244
 //    a.NotContains({"Hello": "World"}, "Earth", "But {'Hello': 'World'} does NOT contain 'Earth'")
272
-// 
245
+//
273 246
 // Returns whether the assertion was successful (true) or not (false).
274 247
 func (a *Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool {
275 248
 	return NotContains(a.t, s, contains, msgAndArgs...)
276 249
 }
277 250
 
278
-
279 251
 // NotEmpty asserts that the specified object is NOT empty.  I.e. not nil, "", false, 0 or either
280 252
 // a slice or a channel with len == 0.
281
-// 
253
+//
282 254
 //  if a.NotEmpty(obj) {
283 255
 //    assert.Equal(t, "two", obj[1])
284 256
 //  }
285
-// 
257
+//
286 258
 // Returns whether the assertion was successful (true) or not (false).
287 259
 func (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) bool {
288 260
 	return NotEmpty(a.t, object, msgAndArgs...)
289 261
 }
290 262
 
291
-
292 263
 // NotEqual asserts that the specified values are NOT equal.
293
-// 
264
+//
294 265
 //    a.NotEqual(obj1, obj2, "two objects shouldn't be equal")
295
-// 
266
+//
296 267
 // Returns whether the assertion was successful (true) or not (false).
268
+//
269
+// Pointer variable equality is determined based on the equality of the
270
+// referenced values (as opposed to the memory addresses).
297 271
 func (a *Assertions) NotEqual(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
298 272
 	return NotEqual(a.t, expected, actual, msgAndArgs...)
299 273
 }
300 274
 
301
-
302 275
 // NotNil asserts that the specified object is not nil.
303
-// 
276
+//
304 277
 //    a.NotNil(err, "err should be something")
305
-// 
278
+//
306 279
 // Returns whether the assertion was successful (true) or not (false).
307 280
 func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) bool {
308 281
 	return NotNil(a.t, object, msgAndArgs...)
309 282
 }
310 283
 
311
-
312 284
 // NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
313
-// 
285
+//
314 286
 //   a.NotPanics(func(){
315 287
 //     RemainCalm()
316 288
 //   }, "Calling RemainCalm() should NOT panic")
317
-// 
289
+//
318 290
 // Returns whether the assertion was successful (true) or not (false).
319 291
 func (a *Assertions) NotPanics(f PanicTestFunc, msgAndArgs ...interface{}) bool {
320 292
 	return NotPanics(a.t, f, msgAndArgs...)
321 293
 }
322 294
 
323
-
324 295
 // NotRegexp asserts that a specified regexp does not match a string.
325
-// 
296
+//
326 297
 //  a.NotRegexp(regexp.MustCompile("starts"), "it's starting")
327 298
 //  a.NotRegexp("^start", "it's not starting")
328
-// 
299
+//
329 300
 // Returns whether the assertion was successful (true) or not (false).
330 301
 func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool {
331 302
 	return NotRegexp(a.t, rx, str, msgAndArgs...)
332 303
 }
333 304
 
334
-
335 305
 // NotZero asserts that i is not the zero value for its type and returns the truth.
336 306
 func (a *Assertions) NotZero(i interface{}, msgAndArgs ...interface{}) bool {
337 307
 	return NotZero(a.t, i, msgAndArgs...)
338 308
 }
339 309
 
340
-
341 310
 // Panics asserts that the code inside the specified PanicTestFunc panics.
342
-// 
311
+//
343 312
 //   a.Panics(func(){
344 313
 //     GoCrazy()
345 314
 //   }, "Calling GoCrazy() should panic")
346
-// 
315
+//
347 316
 // Returns whether the assertion was successful (true) or not (false).
348 317
 func (a *Assertions) Panics(f PanicTestFunc, msgAndArgs ...interface{}) bool {
349 318
 	return Panics(a.t, f, msgAndArgs...)
350 319
 }
351 320
 
352
-
353 321
 // Regexp asserts that a specified regexp matches a string.
354
-// 
322
+//
355 323
 //  a.Regexp(regexp.MustCompile("start"), "it's starting")
356 324
 //  a.Regexp("start...$", "it's not starting")
357
-// 
325
+//
358 326
 // Returns whether the assertion was successful (true) or not (false).
359 327
 func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool {
360 328
 	return Regexp(a.t, rx, str, msgAndArgs...)
361 329
 }
362 330
 
363
-
364 331
 // True asserts that the specified value is true.
365
-// 
332
+//
366 333
 //    a.True(myBool, "myBool should be true")
367
-// 
334
+//
368 335
 // Returns whether the assertion was successful (true) or not (false).
369 336
 func (a *Assertions) True(value bool, msgAndArgs ...interface{}) bool {
370 337
 	return True(a.t, value, msgAndArgs...)
371 338
 }
372 339
 
373
-
374 340
 // WithinDuration asserts that the two times are within duration delta of each other.
375
-// 
341
+//
376 342
 //   a.WithinDuration(time.Now(), time.Now(), 10*time.Second, "The difference should not be more than 10s")
377
-// 
343
+//
378 344
 // Returns whether the assertion was successful (true) or not (false).
379 345
 func (a *Assertions) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) bool {
380 346
 	return WithinDuration(a.t, expected, actual, delta, msgAndArgs...)
381 347
 }
382 348
 
383
-
384 349
 // Zero asserts that i is the zero value for its type and returns the truth.
385 350
 func (a *Assertions) Zero(i interface{}, msgAndArgs ...interface{}) bool {
386 351
 	return Zero(a.t, i, msgAndArgs...)
... ...
@@ -65,7 +65,7 @@ func ObjectsAreEqualValues(expected, actual interface{}) bool {
65 65
 
66 66
 /* CallerInfo is necessary because the assert functions use the testing object
67 67
 internally, causing it to print the file:line of the assert method, rather than where
68
-the problem actually occured in calling code.*/
68
+the problem actually occurred in calling code.*/
69 69
 
70 70
 // CallerInfo returns an array of strings containing the file and line number
71 71
 // of each stack frame leading from the current test to the assert call that
... ...
@@ -82,7 +82,9 @@ func CallerInfo() []string {
82 82
 	for i := 0; ; i++ {
83 83
 		pc, file, line, ok = runtime.Caller(i)
84 84
 		if !ok {
85
-			return nil
85
+			// The breaks below failed to terminate the loop, and we ran off the
86
+			// end of the call stack.
87
+			break
86 88
 		}
87 89
 
88 90
 		// This is a huge edge case, but it will panic if this is the case, see #180
... ...
@@ -90,6 +92,21 @@ func CallerInfo() []string {
90 90
 			break
91 91
 		}
92 92
 
93
+		f := runtime.FuncForPC(pc)
94
+		if f == nil {
95
+			break
96
+		}
97
+		name = f.Name()
98
+
99
+		// testing.tRunner is the standard library function that calls
100
+		// tests. Subtests are called directly by tRunner, without going through
101
+		// the Test/Benchmark/Example function that contains the t.Run calls, so
102
+		// with subtests we should break when we hit tRunner, without adding it
103
+		// to the list of callers.
104
+		if name == "testing.tRunner" {
105
+			break
106
+		}
107
+
93 108
 		parts := strings.Split(file, "/")
94 109
 		dir := parts[len(parts)-2]
95 110
 		file = parts[len(parts)-1]
... ...
@@ -97,11 +114,6 @@ func CallerInfo() []string {
97 97
 			callers = append(callers, fmt.Sprintf("%s:%d", file, line))
98 98
 		}
99 99
 
100
-		f := runtime.FuncForPC(pc)
101
-		if f == nil {
102
-			break
103
-		}
104
-		name = f.Name()
105 100
 		// Drop the package
106 101
 		segments := strings.Split(name, ".")
107 102
 		name = segments[len(segments)-1]
... ...
@@ -141,7 +153,7 @@ func getWhitespaceString() string {
141 141
 	parts := strings.Split(file, "/")
142 142
 	file = parts[len(parts)-1]
143 143
 
144
-	return strings.Repeat(" ", len(fmt.Sprintf("%s:%d:      ", file, line)))
144
+	return strings.Repeat(" ", len(fmt.Sprintf("%s:%d:        ", file, line)))
145 145
 
146 146
 }
147 147
 
... ...
@@ -158,22 +170,18 @@ func messageFromMsgAndArgs(msgAndArgs ...interface{}) string {
158 158
 	return ""
159 159
 }
160 160
 
161
-// Indents all lines of the message by appending a number of tabs to each line, in an output format compatible with Go's
162
-// test printing (see inner comment for specifics)
163
-func indentMessageLines(message string, tabs int) string {
161
+// Aligns the provided message so that all lines after the first line start at the same location as the first line.
162
+// Assumes that the first line starts at the correct location (after carriage return, tab, label, spacer and tab).
163
+// The longestLabelLen parameter specifies the length of the longest label in the output (required becaues this is the
164
+// basis on which the alignment occurs).
165
+func indentMessageLines(message string, longestLabelLen int) string {
164 166
 	outBuf := new(bytes.Buffer)
165 167
 
166 168
 	for i, scanner := 0, bufio.NewScanner(strings.NewReader(message)); scanner.Scan(); i++ {
169
+		// no need to align first line because it starts at the correct location (after the label)
167 170
 		if i != 0 {
168
-			outBuf.WriteRune('\n')
169
-		}
170
-		for ii := 0; ii < tabs; ii++ {
171
-			outBuf.WriteRune('\t')
172
-			// Bizarrely, all lines except the first need one fewer tabs prepended, so deliberately advance the counter
173
-			// by 1 prematurely.
174
-			if ii == 0 && i > 0 {
175
-				ii++
176
-			}
171
+			// append alignLen+1 spaces to align with "{{longestLabel}}:" before adding tab
172
+			outBuf.WriteString("\n\r\t" + strings.Repeat(" ", longestLabelLen +1) + "\t")
177 173
 		}
178 174
 		outBuf.WriteString(scanner.Text())
179 175
 	}
... ...
@@ -205,29 +213,49 @@ func FailNow(t TestingT, failureMessage string, msgAndArgs ...interface{}) bool
205 205
 
206 206
 // Fail reports a failure through
207 207
 func Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) bool {
208
+	content := []labeledContent{
209
+		{"Error Trace", strings.Join(CallerInfo(), "\n\r\t\t\t")},
210
+		{"Error", failureMessage},
211
+	}
208 212
 
209 213
 	message := messageFromMsgAndArgs(msgAndArgs...)
210
-
211
-	errorTrace := strings.Join(CallerInfo(), "\n\r\t\t\t")
212 214
 	if len(message) > 0 {
213
-		t.Errorf("\r%s\r\tError Trace:\t%s\n"+
214
-			"\r\tError:%s\n"+
215
-			"\r\tMessages:\t%s\n\r",
216
-			getWhitespaceString(),
217
-			errorTrace,
218
-			indentMessageLines(failureMessage, 2),
219
-			message)
220
-	} else {
221
-		t.Errorf("\r%s\r\tError Trace:\t%s\n"+
222
-			"\r\tError:%s\n\r",
223
-			getWhitespaceString(),
224
-			errorTrace,
225
-			indentMessageLines(failureMessage, 2))
215
+		content = append(content, labeledContent{"Messages", message})
226 216
 	}
227 217
 
218
+	t.Errorf("\r" + getWhitespaceString() + labeledOutput(content...))
219
+
228 220
 	return false
229 221
 }
230 222
 
223
+type labeledContent struct {
224
+	label string
225
+	content string
226
+}
227
+
228
+// labeledOutput returns a string consisting of the provided labeledContent. Each labeled output is appended in the following manner:
229
+//
230
+//   \r\t{{label}}:{{align_spaces}}\t{{content}}\n
231
+//
232
+// The initial carriage return is required to undo/erase any padding added by testing.T.Errorf. The "\t{{label}}:" is for the label.
233
+// If a label is shorter than the longest label provided, padding spaces are added to make all the labels match in length. Once this
234
+// alignment is achieved, "\t{{content}}\n" is added for the output.
235
+//
236
+// If the content of the labeledOutput contains line breaks, the subsequent lines are aligned so that they start at the same location as the first line.
237
+func labeledOutput(content ...labeledContent) string {
238
+	longestLabel := 0
239
+	for _, v := range content {
240
+		if len(v.label) > longestLabel {
241
+			longestLabel = len(v.label)
242
+		}
243
+	}
244
+	var output string
245
+	for _, v := range content {
246
+		output += "\r\t" + v.label + ":" + strings.Repeat(" ", longestLabel-len(v.label)) + "\t" + indentMessageLines(v.content, longestLabel) + "\n"
247
+	}
248
+	return output
249
+}
250
+
231 251
 // Implements asserts that an object is implemented by the specified interface.
232 252
 //
233 253
 //    assert.Implements(t, (*MyInterface)(nil), new(MyObject), "MyObject")
... ...
@@ -258,18 +286,39 @@ func IsType(t TestingT, expectedType interface{}, object interface{}, msgAndArgs
258 258
 //    assert.Equal(t, 123, 123, "123 and 123 should be equal")
259 259
 //
260 260
 // Returns whether the assertion was successful (true) or not (false).
261
+//
262
+// Pointer variable equality is determined based on the equality of the
263
+// referenced values (as opposed to the memory addresses).
261 264
 func Equal(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
262 265
 
263 266
 	if !ObjectsAreEqual(expected, actual) {
264 267
 		diff := diff(expected, actual)
265
-		return Fail(t, fmt.Sprintf("Not equal: %#v (expected)\n"+
266
-			"        != %#v (actual)%s", expected, actual, diff), msgAndArgs...)
268
+		expected, actual = formatUnequalValues(expected, actual)
269
+		return Fail(t, fmt.Sprintf("Not equal: \n"+
270
+			"expected: %s\n"+
271
+			"received: %s%s", expected, actual, diff), msgAndArgs...)
267 272
 	}
268 273
 
269 274
 	return true
270 275
 
271 276
 }
272 277
 
278
+// formatUnequalValues takes two values of arbitrary types and returns string
279
+// representations appropriate to be presented to the user.
280
+//
281
+// If the values are not of like type, the returned strings will be prefixed
282
+// with the type name, and the value will be enclosed in parenthesis similar
283
+// to a type conversion in the Go grammar.
284
+func formatUnequalValues(expected, actual interface{}) (e string, a string) {
285
+	if reflect.TypeOf(expected) != reflect.TypeOf(actual) {
286
+		return fmt.Sprintf("%T(%#v)", expected, expected),
287
+			fmt.Sprintf("%T(%#v)", actual, actual)
288
+	}
289
+
290
+	return fmt.Sprintf("%#v", expected),
291
+		fmt.Sprintf("%#v", actual)
292
+}
293
+
273 294
 // EqualValues asserts that two objects are equal or convertable to the same types
274 295
 // and equal.
275 296
 //
... ...
@@ -279,8 +328,11 @@ func Equal(t TestingT, expected, actual interface{}, msgAndArgs ...interface{})
279 279
 func EqualValues(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
280 280
 
281 281
 	if !ObjectsAreEqualValues(expected, actual) {
282
-		return Fail(t, fmt.Sprintf("Not equal: %#v (expected)\n"+
283
-			"        != %#v (actual)", expected, actual), msgAndArgs...)
282
+		diff := diff(expected, actual)
283
+		expected, actual = formatUnequalValues(expected, actual)
284
+		return Fail(t, fmt.Sprintf("Not equal: \n"+
285
+			"expected: %s\n"+
286
+			"received: %s%s", expected, actual, diff), msgAndArgs...)
284 287
 	}
285 288
 
286 289
 	return true
... ...
@@ -507,6 +559,9 @@ func False(t TestingT, value bool, msgAndArgs ...interface{}) bool {
507 507
 //    assert.NotEqual(t, obj1, obj2, "two objects shouldn't be equal")
508 508
 //
509 509
 // Returns whether the assertion was successful (true) or not (false).
510
+//
511
+// Pointer variable equality is determined based on the equality of the
512
+// referenced values (as opposed to the memory addresses).
510 513
 func NotEqual(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
511 514
 
512 515
 	if ObjectsAreEqual(expected, actual) {
... ...
@@ -832,11 +887,11 @@ func InEpsilonSlice(t TestingT, expected, actual interface{}, epsilon float64, m
832 832
 //
833 833
 // Returns whether the assertion was successful (true) or not (false).
834 834
 func NoError(t TestingT, err error, msgAndArgs ...interface{}) bool {
835
-	if isNil(err) {
836
-		return true
835
+	if err != nil {
836
+		return Fail(t, fmt.Sprintf("Received unexpected error:\n%+v", err), msgAndArgs...)
837 837
 	}
838 838
 
839
-	return Fail(t, fmt.Sprintf("Received unexpected error %q", err), msgAndArgs...)
839
+	return true
840 840
 }
841 841
 
842 842
 // Error asserts that a function returned an error (i.e. not `nil`).
... ...
@@ -849,29 +904,33 @@ func NoError(t TestingT, err error, msgAndArgs ...interface{}) bool {
849 849
 // Returns whether the assertion was successful (true) or not (false).
850 850
 func Error(t TestingT, err error, msgAndArgs ...interface{}) bool {
851 851
 
852
-	message := messageFromMsgAndArgs(msgAndArgs...)
853
-	return NotNil(t, err, "An error is expected but got nil. %s", message)
852
+	if err == nil {
853
+		return Fail(t, "An error is expected but got nil.", msgAndArgs...)
854
+	}
854 855
 
856
+	return true
855 857
 }
856 858
 
857 859
 // EqualError asserts that a function returned an error (i.e. not `nil`)
858 860
 // and that it is equal to the provided error.
859 861
 //
860 862
 //   actualObj, err := SomeFunction()
861
-//   if assert.Error(t, err, "An error was expected") {
862
-//	   assert.Equal(t, err, expectedError)
863
-//   }
863
+//   assert.EqualError(t, err,  expectedErrorString, "An error was expected")
864 864
 //
865 865
 // Returns whether the assertion was successful (true) or not (false).
866 866
 func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{}) bool {
867
-
868
-	message := messageFromMsgAndArgs(msgAndArgs...)
869
-	if !NotNil(t, theError, "An error is expected but got nil. %s", message) {
867
+	if !Error(t, theError, msgAndArgs...) {
870 868
 		return false
871 869
 	}
872
-	s := "An error with value \"%s\" is expected but got \"%s\". %s"
873
-	return Equal(t, errString, theError.Error(),
874
-		s, errString, theError.Error(), message)
870
+	expected := errString
871
+	actual := theError.Error()
872
+	// don't need to use deep equals here, we know they are both strings
873
+	if expected != actual {
874
+		return Fail(t, fmt.Sprintf("Error message not equal:\n"+
875
+			"expected: %q\n"+
876
+			"received: %q", expected, actual), msgAndArgs...)
877
+	}
878
+	return true
875 879
 }
876 880
 
877 881
 // matchRegexp return true if a specified regexp matches a string.
... ...
@@ -986,9 +1045,8 @@ func diff(expected interface{}, actual interface{}) string {
986 986
 		return ""
987 987
 	}
988 988
 
989
-	spew.Config.SortKeys = true
990
-	e := spew.Sdump(expected)
991
-	a := spew.Sdump(actual)
989
+	e := spewConfig.Sdump(expected)
990
+	a := spewConfig.Sdump(actual)
992 991
 
993 992
 	diff, _ := difflib.GetUnifiedDiffString(difflib.UnifiedDiff{
994 993
 		A:        difflib.SplitLines(e),
... ...
@@ -1002,3 +1060,10 @@ func diff(expected interface{}, actual interface{}) string {
1002 1002
 
1003 1003
 	return "\n\nDiff:\n" + diff
1004 1004
 }
1005
+
1006
+var spewConfig = spew.ConfigState{
1007
+	Indent:                  " ",
1008
+	DisablePointerAddresses: true,
1009
+	DisableCapacities:       true,
1010
+	SortKeys:                true,
1011
+}
... ...
@@ -99,7 +99,7 @@ func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method, url strin
99 99
 
100 100
 	contains := strings.Contains(body, fmt.Sprint(str))
101 101
 	if contains {
102
-		Fail(t, "Expected response body for %s to NOT contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body)
102
+		Fail(t, fmt.Sprintf("Expected response body for \"%s\" to NOT contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body))
103 103
 	}
104 104
 
105 105
 	return !contains
106 106
new file mode 100644
... ...
@@ -0,0 +1,28 @@
0
+// Package require implements the same assertions as the `assert` package but
1
+// stops test execution when a test fails.
2
+//
3
+// Example Usage
4
+//
5
+// The following is a complete example using require in a standard test function:
6
+//    import (
7
+//      "testing"
8
+//      "github.com/stretchr/testify/require"
9
+//    )
10
+//
11
+//    func TestSomething(t *testing.T) {
12
+//
13
+//      var a string = "Hello"
14
+//      var b string = "Hello"
15
+//
16
+//      require.Equal(t, a, b, "The two words should be the same.")
17
+//
18
+//    }
19
+//
20
+// Assertions
21
+//
22
+// The `require` package have same global functions as in the `assert` package,
23
+// but instead of returning a boolean result they call `t.FailNow()`.
24
+//
25
+// Every assertion function also takes an optional string message as the final argument,
26
+// allowing custom error messages to be appended to the message the assertion method outputs.
27
+package require
0 28
new file mode 100644
... ...
@@ -0,0 +1,16 @@
0
+package require
1
+
2
+// Assertions provides assertion methods around the
3
+// TestingT interface.
4
+type Assertions struct {
5
+	t TestingT
6
+}
7
+
8
+// New makes a new Assertions object for the specified TestingT.
9
+func New(t TestingT) *Assertions {
10
+	return &Assertions{
11
+		t: t,
12
+	}
13
+}
14
+
15
+//go:generate go run ../_codegen/main.go -output-package=require -template=require_forward.go.tmpl
0 16
new file mode 100644
... ...
@@ -0,0 +1,429 @@
0
+/*
1
+* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen
2
+* THIS FILE MUST NOT BE EDITED BY HAND
3
+ */
4
+
5
+package require
6
+
7
+import (
8
+	assert "github.com/stretchr/testify/assert"
9
+	http "net/http"
10
+	url "net/url"
11
+	time "time"
12
+)
13
+
14
+// Condition uses a Comparison to assert a complex condition.
15
+func Condition(t TestingT, comp assert.Comparison, msgAndArgs ...interface{}) {
16
+	if !assert.Condition(t, comp, msgAndArgs...) {
17
+		t.FailNow()
18
+	}
19
+}
20
+
21
+// Contains asserts that the specified string, list(array, slice...) or map contains the
22
+// specified substring or element.
23
+//
24
+//    assert.Contains(t, "Hello World", "World", "But 'Hello World' does contain 'World'")
25
+//    assert.Contains(t, ["Hello", "World"], "World", "But ["Hello", "World"] does contain 'World'")
26
+//    assert.Contains(t, {"Hello": "World"}, "Hello", "But {'Hello': 'World'} does contain 'Hello'")
27
+//
28
+// Returns whether the assertion was successful (true) or not (false).
29
+func Contains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) {
30
+	if !assert.Contains(t, s, contains, msgAndArgs...) {
31
+		t.FailNow()
32
+	}
33
+}
34
+
35
+// Empty asserts that the specified object is empty.  I.e. nil, "", false, 0 or either
36
+// a slice or a channel with len == 0.
37
+//
38
+//  assert.Empty(t, obj)
39
+//
40
+// Returns whether the assertion was successful (true) or not (false).
41
+func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) {
42
+	if !assert.Empty(t, object, msgAndArgs...) {
43
+		t.FailNow()
44
+	}
45
+}
46
+
47
+// Equal asserts that two objects are equal.
48
+//
49
+//    assert.Equal(t, 123, 123, "123 and 123 should be equal")
50
+//
51
+// Returns whether the assertion was successful (true) or not (false).
52
+//
53
+// Pointer variable equality is determined based on the equality of the
54
+// referenced values (as opposed to the memory addresses).
55
+func Equal(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
56
+	if !assert.Equal(t, expected, actual, msgAndArgs...) {
57
+		t.FailNow()
58
+	}
59
+}
60
+
61
+// EqualError asserts that a function returned an error (i.e. not `nil`)
62
+// and that it is equal to the provided error.
63
+//
64
+//   actualObj, err := SomeFunction()
65
+//   assert.EqualError(t, err,  expectedErrorString, "An error was expected")
66
+//
67
+// Returns whether the assertion was successful (true) or not (false).
68
+func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{}) {
69
+	if !assert.EqualError(t, theError, errString, msgAndArgs...) {
70
+		t.FailNow()
71
+	}
72
+}
73
+
74
+// EqualValues asserts that two objects are equal or convertable to the same types
75
+// and equal.
76
+//
77
+//    assert.EqualValues(t, uint32(123), int32(123), "123 and 123 should be equal")
78
+//
79
+// Returns whether the assertion was successful (true) or not (false).
80
+func EqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
81
+	if !assert.EqualValues(t, expected, actual, msgAndArgs...) {
82
+		t.FailNow()
83
+	}
84
+}
85
+
86
+// Error asserts that a function returned an error (i.e. not `nil`).
87
+//
88
+//   actualObj, err := SomeFunction()
89
+//   if assert.Error(t, err, "An error was expected") {
90
+// 	   assert.Equal(t, err, expectedError)
91
+//   }
92
+//
93
+// Returns whether the assertion was successful (true) or not (false).
94
+func Error(t TestingT, err error, msgAndArgs ...interface{}) {
95
+	if !assert.Error(t, err, msgAndArgs...) {
96
+		t.FailNow()
97
+	}
98
+}
99
+
100
+// Exactly asserts that two objects are equal is value and type.
101
+//
102
+//    assert.Exactly(t, int32(123), int64(123), "123 and 123 should NOT be equal")
103
+//
104
+// Returns whether the assertion was successful (true) or not (false).
105
+func Exactly(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
106
+	if !assert.Exactly(t, expected, actual, msgAndArgs...) {
107
+		t.FailNow()
108
+	}
109
+}
110
+
111
+// Fail reports a failure through
112
+func Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) {
113
+	if !assert.Fail(t, failureMessage, msgAndArgs...) {
114
+		t.FailNow()
115
+	}
116
+}
117
+
118
+// FailNow fails test
119
+func FailNow(t TestingT, failureMessage string, msgAndArgs ...interface{}) {
120
+	if !assert.FailNow(t, failureMessage, msgAndArgs...) {
121
+		t.FailNow()
122
+	}
123
+}
124
+
125
+// False asserts that the specified value is false.
126
+//
127
+//    assert.False(t, myBool, "myBool should be false")
128
+//
129
+// Returns whether the assertion was successful (true) or not (false).
130
+func False(t TestingT, value bool, msgAndArgs ...interface{}) {
131
+	if !assert.False(t, value, msgAndArgs...) {
132
+		t.FailNow()
133
+	}
134
+}
135
+
136
+// HTTPBodyContains asserts that a specified handler returns a
137
+// body that contains a string.
138
+//
139
+//  assert.HTTPBodyContains(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky")
140
+//
141
+// Returns whether the assertion was successful (true) or not (false).
142
+func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) {
143
+	if !assert.HTTPBodyContains(t, handler, method, url, values, str) {
144
+		t.FailNow()
145
+	}
146
+}
147
+
148
+// HTTPBodyNotContains asserts that a specified handler returns a
149
+// body that does not contain a string.
150
+//
151
+//  assert.HTTPBodyNotContains(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky")
152
+//
153
+// Returns whether the assertion was successful (true) or not (false).
154
+func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) {
155
+	if !assert.HTTPBodyNotContains(t, handler, method, url, values, str) {
156
+		t.FailNow()
157
+	}
158
+}
159
+
160
+// HTTPError asserts that a specified handler returns an error status code.
161
+//
162
+//  assert.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
163
+//
164
+// Returns whether the assertion was successful (true) or not (false).
165
+func HTTPError(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values) {
166
+	if !assert.HTTPError(t, handler, method, url, values) {
167
+		t.FailNow()
168
+	}
169
+}
170
+
171
+// HTTPRedirect asserts that a specified handler returns a redirect status code.
172
+//
173
+//  assert.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
174
+//
175
+// Returns whether the assertion was successful (true) or not (false).
176
+func HTTPRedirect(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values) {
177
+	if !assert.HTTPRedirect(t, handler, method, url, values) {
178
+		t.FailNow()
179
+	}
180
+}
181
+
182
+// HTTPSuccess asserts that a specified handler returns a success status code.
183
+//
184
+//  assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil)
185
+//
186
+// Returns whether the assertion was successful (true) or not (false).
187
+func HTTPSuccess(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values) {
188
+	if !assert.HTTPSuccess(t, handler, method, url, values) {
189
+		t.FailNow()
190
+	}
191
+}
192
+
193
+// Implements asserts that an object is implemented by the specified interface.
194
+//
195
+//    assert.Implements(t, (*MyInterface)(nil), new(MyObject), "MyObject")
196
+func Implements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) {
197
+	if !assert.Implements(t, interfaceObject, object, msgAndArgs...) {
198
+		t.FailNow()
199
+	}
200
+}
201
+
202
+// InDelta asserts that the two numerals are within delta of each other.
203
+//
204
+// 	 assert.InDelta(t, math.Pi, (22 / 7.0), 0.01)
205
+//
206
+// Returns whether the assertion was successful (true) or not (false).
207
+func InDelta(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
208
+	if !assert.InDelta(t, expected, actual, delta, msgAndArgs...) {
209
+		t.FailNow()
210
+	}
211
+}
212
+
213
+// InDeltaSlice is the same as InDelta, except it compares two slices.
214
+func InDeltaSlice(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
215
+	if !assert.InDeltaSlice(t, expected, actual, delta, msgAndArgs...) {
216
+		t.FailNow()
217
+	}
218
+}
219
+
220
+// InEpsilon asserts that expected and actual have a relative error less than epsilon
221
+//
222
+// Returns whether the assertion was successful (true) or not (false).
223
+func InEpsilon(t TestingT, expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) {
224
+	if !assert.InEpsilon(t, expected, actual, epsilon, msgAndArgs...) {
225
+		t.FailNow()
226
+	}
227
+}
228
+
229
+// InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices.
230
+func InEpsilonSlice(t TestingT, expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) {
231
+	if !assert.InEpsilonSlice(t, expected, actual, epsilon, msgAndArgs...) {
232
+		t.FailNow()
233
+	}
234
+}
235
+
236
+// IsType asserts that the specified objects are of the same type.
237
+func IsType(t TestingT, expectedType interface{}, object interface{}, msgAndArgs ...interface{}) {
238
+	if !assert.IsType(t, expectedType, object, msgAndArgs...) {
239
+		t.FailNow()
240
+	}
241
+}
242
+
243
+// JSONEq asserts that two JSON strings are equivalent.
244
+//
245
+//  assert.JSONEq(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
246
+//
247
+// Returns whether the assertion was successful (true) or not (false).
248
+func JSONEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) {
249
+	if !assert.JSONEq(t, expected, actual, msgAndArgs...) {
250
+		t.FailNow()
251
+	}
252
+}
253
+
254
+// Len asserts that the specified object has specific length.
255
+// Len also fails if the object has a type that len() not accept.
256
+//
257
+//    assert.Len(t, mySlice, 3, "The size of slice is not 3")
258
+//
259
+// Returns whether the assertion was successful (true) or not (false).
260
+func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) {
261
+	if !assert.Len(t, object, length, msgAndArgs...) {
262
+		t.FailNow()
263
+	}
264
+}
265
+
266
+// Nil asserts that the specified object is nil.
267
+//
268
+//    assert.Nil(t, err, "err should be nothing")
269
+//
270
+// Returns whether the assertion was successful (true) or not (false).
271
+func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) {
272
+	if !assert.Nil(t, object, msgAndArgs...) {
273
+		t.FailNow()
274
+	}
275
+}
276
+
277
+// NoError asserts that a function returned no error (i.e. `nil`).
278
+//
279
+//   actualObj, err := SomeFunction()
280
+//   if assert.NoError(t, err) {
281
+// 	   assert.Equal(t, actualObj, expectedObj)
282
+//   }
283
+//
284
+// Returns whether the assertion was successful (true) or not (false).
285
+func NoError(t TestingT, err error, msgAndArgs ...interface{}) {
286
+	if !assert.NoError(t, err, msgAndArgs...) {
287
+		t.FailNow()
288
+	}
289
+}
290
+
291
+// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
292
+// specified substring or element.
293
+//
294
+//    assert.NotContains(t, "Hello World", "Earth", "But 'Hello World' does NOT contain 'Earth'")
295
+//    assert.NotContains(t, ["Hello", "World"], "Earth", "But ['Hello', 'World'] does NOT contain 'Earth'")
296
+//    assert.NotContains(t, {"Hello": "World"}, "Earth", "But {'Hello': 'World'} does NOT contain 'Earth'")
297
+//
298
+// Returns whether the assertion was successful (true) or not (false).
299
+func NotContains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) {
300
+	if !assert.NotContains(t, s, contains, msgAndArgs...) {
301
+		t.FailNow()
302
+	}
303
+}
304
+
305
+// NotEmpty asserts that the specified object is NOT empty.  I.e. not nil, "", false, 0 or either
306
+// a slice or a channel with len == 0.
307
+//
308
+//  if assert.NotEmpty(t, obj) {
309
+//    assert.Equal(t, "two", obj[1])
310
+//  }
311
+//
312
+// Returns whether the assertion was successful (true) or not (false).
313
+func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) {
314
+	if !assert.NotEmpty(t, object, msgAndArgs...) {
315
+		t.FailNow()
316
+	}
317
+}
318
+
319
+// NotEqual asserts that the specified values are NOT equal.
320
+//
321
+//    assert.NotEqual(t, obj1, obj2, "two objects shouldn't be equal")
322
+//
323
+// Returns whether the assertion was successful (true) or not (false).
324
+//
325
+// Pointer variable equality is determined based on the equality of the
326
+// referenced values (as opposed to the memory addresses).
327
+func NotEqual(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
328
+	if !assert.NotEqual(t, expected, actual, msgAndArgs...) {
329
+		t.FailNow()
330
+	}
331
+}
332
+
333
+// NotNil asserts that the specified object is not nil.
334
+//
335
+//    assert.NotNil(t, err, "err should be something")
336
+//
337
+// Returns whether the assertion was successful (true) or not (false).
338
+func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) {
339
+	if !assert.NotNil(t, object, msgAndArgs...) {
340
+		t.FailNow()
341
+	}
342
+}
343
+
344
+// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
345
+//
346
+//   assert.NotPanics(t, func(){
347
+//     RemainCalm()
348
+//   }, "Calling RemainCalm() should NOT panic")
349
+//
350
+// Returns whether the assertion was successful (true) or not (false).
351
+func NotPanics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
352
+	if !assert.NotPanics(t, f, msgAndArgs...) {
353
+		t.FailNow()
354
+	}
355
+}
356
+
357
+// NotRegexp asserts that a specified regexp does not match a string.
358
+//
359
+//  assert.NotRegexp(t, regexp.MustCompile("starts"), "it's starting")
360
+//  assert.NotRegexp(t, "^start", "it's not starting")
361
+//
362
+// Returns whether the assertion was successful (true) or not (false).
363
+func NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) {
364
+	if !assert.NotRegexp(t, rx, str, msgAndArgs...) {
365
+		t.FailNow()
366
+	}
367
+}
368
+
369
+// NotZero asserts that i is not the zero value for its type and returns the truth.
370
+func NotZero(t TestingT, i interface{}, msgAndArgs ...interface{}) {
371
+	if !assert.NotZero(t, i, msgAndArgs...) {
372
+		t.FailNow()
373
+	}
374
+}
375
+
376
+// Panics asserts that the code inside the specified PanicTestFunc panics.
377
+//
378
+//   assert.Panics(t, func(){
379
+//     GoCrazy()
380
+//   }, "Calling GoCrazy() should panic")
381
+//
382
+// Returns whether the assertion was successful (true) or not (false).
383
+func Panics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
384
+	if !assert.Panics(t, f, msgAndArgs...) {
385
+		t.FailNow()
386
+	}
387
+}
388
+
389
+// Regexp asserts that a specified regexp matches a string.
390
+//
391
+//  assert.Regexp(t, regexp.MustCompile("start"), "it's starting")
392
+//  assert.Regexp(t, "start...$", "it's not starting")
393
+//
394
+// Returns whether the assertion was successful (true) or not (false).
395
+func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) {
396
+	if !assert.Regexp(t, rx, str, msgAndArgs...) {
397
+		t.FailNow()
398
+	}
399
+}
400
+
401
+// True asserts that the specified value is true.
402
+//
403
+//    assert.True(t, myBool, "myBool should be true")
404
+//
405
+// Returns whether the assertion was successful (true) or not (false).
406
+func True(t TestingT, value bool, msgAndArgs ...interface{}) {
407
+	if !assert.True(t, value, msgAndArgs...) {
408
+		t.FailNow()
409
+	}
410
+}
411
+
412
+// WithinDuration asserts that the two times are within duration delta of each other.
413
+//
414
+//   assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second, "The difference should not be more than 10s")
415
+//
416
+// Returns whether the assertion was successful (true) or not (false).
417
+func WithinDuration(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) {
418
+	if !assert.WithinDuration(t, expected, actual, delta, msgAndArgs...) {
419
+		t.FailNow()
420
+	}
421
+}
422
+
423
+// Zero asserts that i is the zero value for its type and returns the truth.
424
+func Zero(t TestingT, i interface{}, msgAndArgs ...interface{}) {
425
+	if !assert.Zero(t, i, msgAndArgs...) {
426
+		t.FailNow()
427
+	}
428
+}
0 429
new file mode 100644
... ...
@@ -0,0 +1,353 @@
0
+/*
1
+* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen
2
+* THIS FILE MUST NOT BE EDITED BY HAND
3
+ */
4
+
5
+package require
6
+
7
+import (
8
+	assert "github.com/stretchr/testify/assert"
9
+	http "net/http"
10
+	url "net/url"
11
+	time "time"
12
+)
13
+
14
+// Condition uses a Comparison to assert a complex condition.
15
+func (a *Assertions) Condition(comp assert.Comparison, msgAndArgs ...interface{}) {
16
+	Condition(a.t, comp, msgAndArgs...)
17
+}
18
+
19
+// Contains asserts that the specified string, list(array, slice...) or map contains the
20
+// specified substring or element.
21
+//
22
+//    a.Contains("Hello World", "World", "But 'Hello World' does contain 'World'")
23
+//    a.Contains(["Hello", "World"], "World", "But ["Hello", "World"] does contain 'World'")
24
+//    a.Contains({"Hello": "World"}, "Hello", "But {'Hello': 'World'} does contain 'Hello'")
25
+//
26
+// Returns whether the assertion was successful (true) or not (false).
27
+func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) {
28
+	Contains(a.t, s, contains, msgAndArgs...)
29
+}
30
+
31
+// Empty asserts that the specified object is empty.  I.e. nil, "", false, 0 or either
32
+// a slice or a channel with len == 0.
33
+//
34
+//  a.Empty(obj)
35
+//
36
+// Returns whether the assertion was successful (true) or not (false).
37
+func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) {
38
+	Empty(a.t, object, msgAndArgs...)
39
+}
40
+
41
+// Equal asserts that two objects are equal.
42
+//
43
+//    a.Equal(123, 123, "123 and 123 should be equal")
44
+//
45
+// Returns whether the assertion was successful (true) or not (false).
46
+//
47
+// Pointer variable equality is determined based on the equality of the
48
+// referenced values (as opposed to the memory addresses).
49
+func (a *Assertions) Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
50
+	Equal(a.t, expected, actual, msgAndArgs...)
51
+}
52
+
53
+// EqualError asserts that a function returned an error (i.e. not `nil`)
54
+// and that it is equal to the provided error.
55
+//
56
+//   actualObj, err := SomeFunction()
57
+//   a.EqualError(err,  expectedErrorString, "An error was expected")
58
+//
59
+// Returns whether the assertion was successful (true) or not (false).
60
+func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ...interface{}) {
61
+	EqualError(a.t, theError, errString, msgAndArgs...)
62
+}
63
+
64
+// EqualValues asserts that two objects are equal or convertable to the same types
65
+// and equal.
66
+//
67
+//    a.EqualValues(uint32(123), int32(123), "123 and 123 should be equal")
68
+//
69
+// Returns whether the assertion was successful (true) or not (false).
70
+func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
71
+	EqualValues(a.t, expected, actual, msgAndArgs...)
72
+}
73
+
74
+// Error asserts that a function returned an error (i.e. not `nil`).
75
+//
76
+//   actualObj, err := SomeFunction()
77
+//   if a.Error(err, "An error was expected") {
78
+// 	   assert.Equal(t, err, expectedError)
79
+//   }
80
+//
81
+// Returns whether the assertion was successful (true) or not (false).
82
+func (a *Assertions) Error(err error, msgAndArgs ...interface{}) {
83
+	Error(a.t, err, msgAndArgs...)
84
+}
85
+
86
+// Exactly asserts that two objects are equal is value and type.
87
+//
88
+//    a.Exactly(int32(123), int64(123), "123 and 123 should NOT be equal")
89
+//
90
+// Returns whether the assertion was successful (true) or not (false).
91
+func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
92
+	Exactly(a.t, expected, actual, msgAndArgs...)
93
+}
94
+
95
+// Fail reports a failure through
96
+func (a *Assertions) Fail(failureMessage string, msgAndArgs ...interface{}) {
97
+	Fail(a.t, failureMessage, msgAndArgs...)
98
+}
99
+
100
+// FailNow fails test
101
+func (a *Assertions) FailNow(failureMessage string, msgAndArgs ...interface{}) {
102
+	FailNow(a.t, failureMessage, msgAndArgs...)
103
+}
104
+
105
+// False asserts that the specified value is false.
106
+//
107
+//    a.False(myBool, "myBool should be false")
108
+//
109
+// Returns whether the assertion was successful (true) or not (false).
110
+func (a *Assertions) False(value bool, msgAndArgs ...interface{}) {
111
+	False(a.t, value, msgAndArgs...)
112
+}
113
+
114
+// HTTPBodyContains asserts that a specified handler returns a
115
+// body that contains a string.
116
+//
117
+//  a.HTTPBodyContains(myHandler, "www.google.com", nil, "I'm Feeling Lucky")
118
+//
119
+// Returns whether the assertion was successful (true) or not (false).
120
+func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) {
121
+	HTTPBodyContains(a.t, handler, method, url, values, str)
122
+}
123
+
124
+// HTTPBodyNotContains asserts that a specified handler returns a
125
+// body that does not contain a string.
126
+//
127
+//  a.HTTPBodyNotContains(myHandler, "www.google.com", nil, "I'm Feeling Lucky")
128
+//
129
+// Returns whether the assertion was successful (true) or not (false).
130
+func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) {
131
+	HTTPBodyNotContains(a.t, handler, method, url, values, str)
132
+}
133
+
134
+// HTTPError asserts that a specified handler returns an error status code.
135
+//
136
+//  a.HTTPError(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
137
+//
138
+// Returns whether the assertion was successful (true) or not (false).
139
+func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values) {
140
+	HTTPError(a.t, handler, method, url, values)
141
+}
142
+
143
+// HTTPRedirect asserts that a specified handler returns a redirect status code.
144
+//
145
+//  a.HTTPRedirect(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
146
+//
147
+// Returns whether the assertion was successful (true) or not (false).
148
+func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values) {
149
+	HTTPRedirect(a.t, handler, method, url, values)
150
+}
151
+
152
+// HTTPSuccess asserts that a specified handler returns a success status code.
153
+//
154
+//  a.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil)
155
+//
156
+// Returns whether the assertion was successful (true) or not (false).
157
+func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values) {
158
+	HTTPSuccess(a.t, handler, method, url, values)
159
+}
160
+
161
+// Implements asserts that an object is implemented by the specified interface.
162
+//
163
+//    a.Implements((*MyInterface)(nil), new(MyObject), "MyObject")
164
+func (a *Assertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) {
165
+	Implements(a.t, interfaceObject, object, msgAndArgs...)
166
+}
167
+
168
+// InDelta asserts that the two numerals are within delta of each other.
169
+//
170
+// 	 a.InDelta(math.Pi, (22 / 7.0), 0.01)
171
+//
172
+// Returns whether the assertion was successful (true) or not (false).
173
+func (a *Assertions) InDelta(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
174
+	InDelta(a.t, expected, actual, delta, msgAndArgs...)
175
+}
176
+
177
+// InDeltaSlice is the same as InDelta, except it compares two slices.
178
+func (a *Assertions) InDeltaSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
179
+	InDeltaSlice(a.t, expected, actual, delta, msgAndArgs...)
180
+}
181
+
182
+// InEpsilon asserts that expected and actual have a relative error less than epsilon
183
+//
184
+// Returns whether the assertion was successful (true) or not (false).
185
+func (a *Assertions) InEpsilon(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) {
186
+	InEpsilon(a.t, expected, actual, epsilon, msgAndArgs...)
187
+}
188
+
189
+// InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices.
190
+func (a *Assertions) InEpsilonSlice(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) {
191
+	InEpsilonSlice(a.t, expected, actual, epsilon, msgAndArgs...)
192
+}
193
+
194
+// IsType asserts that the specified objects are of the same type.
195
+func (a *Assertions) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) {
196
+	IsType(a.t, expectedType, object, msgAndArgs...)
197
+}
198
+
199
+// JSONEq asserts that two JSON strings are equivalent.
200
+//
201
+//  a.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
202
+//
203
+// Returns whether the assertion was successful (true) or not (false).
204
+func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interface{}) {
205
+	JSONEq(a.t, expected, actual, msgAndArgs...)
206
+}
207
+
208
+// Len asserts that the specified object has specific length.
209
+// Len also fails if the object has a type that len() not accept.
210
+//
211
+//    a.Len(mySlice, 3, "The size of slice is not 3")
212
+//
213
+// Returns whether the assertion was successful (true) or not (false).
214
+func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface{}) {
215
+	Len(a.t, object, length, msgAndArgs...)
216
+}
217
+
218
+// Nil asserts that the specified object is nil.
219
+//
220
+//    a.Nil(err, "err should be nothing")
221
+//
222
+// Returns whether the assertion was successful (true) or not (false).
223
+func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) {
224
+	Nil(a.t, object, msgAndArgs...)
225
+}
226
+
227
+// NoError asserts that a function returned no error (i.e. `nil`).
228
+//
229
+//   actualObj, err := SomeFunction()
230
+//   if a.NoError(err) {
231
+// 	   assert.Equal(t, actualObj, expectedObj)
232
+//   }
233
+//
234
+// Returns whether the assertion was successful (true) or not (false).
235
+func (a *Assertions) NoError(err error, msgAndArgs ...interface{}) {
236
+	NoError(a.t, err, msgAndArgs...)
237
+}
238
+
239
+// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
240
+// specified substring or element.
241
+//
242
+//    a.NotContains("Hello World", "Earth", "But 'Hello World' does NOT contain 'Earth'")
243
+//    a.NotContains(["Hello", "World"], "Earth", "But ['Hello', 'World'] does NOT contain 'Earth'")
244
+//    a.NotContains({"Hello": "World"}, "Earth", "But {'Hello': 'World'} does NOT contain 'Earth'")
245
+//
246
+// Returns whether the assertion was successful (true) or not (false).
247
+func (a *Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) {
248
+	NotContains(a.t, s, contains, msgAndArgs...)
249
+}
250
+
251
+// NotEmpty asserts that the specified object is NOT empty.  I.e. not nil, "", false, 0 or either
252
+// a slice or a channel with len == 0.
253
+//
254
+//  if a.NotEmpty(obj) {
255
+//    assert.Equal(t, "two", obj[1])
256
+//  }
257
+//
258
+// Returns whether the assertion was successful (true) or not (false).
259
+func (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) {
260
+	NotEmpty(a.t, object, msgAndArgs...)
261
+}
262
+
263
+// NotEqual asserts that the specified values are NOT equal.
264
+//
265
+//    a.NotEqual(obj1, obj2, "two objects shouldn't be equal")
266
+//
267
+// Returns whether the assertion was successful (true) or not (false).
268
+//
269
+// Pointer variable equality is determined based on the equality of the
270
+// referenced values (as opposed to the memory addresses).
271
+func (a *Assertions) NotEqual(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
272
+	NotEqual(a.t, expected, actual, msgAndArgs...)
273
+}
274
+
275
+// NotNil asserts that the specified object is not nil.
276
+//
277
+//    a.NotNil(err, "err should be something")
278
+//
279
+// Returns whether the assertion was successful (true) or not (false).
280
+func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) {
281
+	NotNil(a.t, object, msgAndArgs...)
282
+}
283
+
284
+// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
285
+//
286
+//   a.NotPanics(func(){
287
+//     RemainCalm()
288
+//   }, "Calling RemainCalm() should NOT panic")
289
+//
290
+// Returns whether the assertion was successful (true) or not (false).
291
+func (a *Assertions) NotPanics(f assert.PanicTestFunc, msgAndArgs ...interface{}) {
292
+	NotPanics(a.t, f, msgAndArgs...)
293
+}
294
+
295
+// NotRegexp asserts that a specified regexp does not match a string.
296
+//
297
+//  a.NotRegexp(regexp.MustCompile("starts"), "it's starting")
298
+//  a.NotRegexp("^start", "it's not starting")
299
+//
300
+// Returns whether the assertion was successful (true) or not (false).
301
+func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) {
302
+	NotRegexp(a.t, rx, str, msgAndArgs...)
303
+}
304
+
305
+// NotZero asserts that i is not the zero value for its type and returns the truth.
306
+func (a *Assertions) NotZero(i interface{}, msgAndArgs ...interface{}) {
307
+	NotZero(a.t, i, msgAndArgs...)
308
+}
309
+
310
+// Panics asserts that the code inside the specified PanicTestFunc panics.
311
+//
312
+//   a.Panics(func(){
313
+//     GoCrazy()
314
+//   }, "Calling GoCrazy() should panic")
315
+//
316
+// Returns whether the assertion was successful (true) or not (false).
317
+func (a *Assertions) Panics(f assert.PanicTestFunc, msgAndArgs ...interface{}) {
318
+	Panics(a.t, f, msgAndArgs...)
319
+}
320
+
321
+// Regexp asserts that a specified regexp matches a string.
322
+//
323
+//  a.Regexp(regexp.MustCompile("start"), "it's starting")
324
+//  a.Regexp("start...$", "it's not starting")
325
+//
326
+// Returns whether the assertion was successful (true) or not (false).
327
+func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) {
328
+	Regexp(a.t, rx, str, msgAndArgs...)
329
+}
330
+
331
+// True asserts that the specified value is true.
332
+//
333
+//    a.True(myBool, "myBool should be true")
334
+//
335
+// Returns whether the assertion was successful (true) or not (false).
336
+func (a *Assertions) True(value bool, msgAndArgs ...interface{}) {
337
+	True(a.t, value, msgAndArgs...)
338
+}
339
+
340
+// WithinDuration asserts that the two times are within duration delta of each other.
341
+//
342
+//   a.WithinDuration(time.Now(), time.Now(), 10*time.Second, "The difference should not be more than 10s")
343
+//
344
+// Returns whether the assertion was successful (true) or not (false).
345
+func (a *Assertions) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) {
346
+	WithinDuration(a.t, expected, actual, delta, msgAndArgs...)
347
+}
348
+
349
+// Zero asserts that i is the zero value for its type and returns the truth.
350
+func (a *Assertions) Zero(i interface{}, msgAndArgs ...interface{}) {
351
+	Zero(a.t, i, msgAndArgs...)
352
+}
0 353
new file mode 100644
... ...
@@ -0,0 +1,9 @@
0
+package require
1
+
2
+// TestingT is an interface wrapper around *testing.T
3
+type TestingT interface {
4
+	Errorf(format string, args ...interface{})
5
+	FailNow()
6
+}
7
+
8
+//go:generate go run ../_codegen/main.go -output-package=require -template=require.go.tmpl