Skip to content

Commit

Permalink
Automated migration using
Browse files Browse the repository at this point in the history
gty-migrate-from-testify --ignore-build-tags

Signed-off-by: Daniel Nephin <[email protected]>
  • Loading branch information
dnephin committed Mar 16, 2018
1 parent ef01dea commit 6be0f70
Show file tree
Hide file tree
Showing 183 changed files with 2,257 additions and 2,203 deletions.
5 changes: 3 additions & 2 deletions api/server/middleware/debug_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package middleware // import "github.com/docker/docker/api/server/middleware"
import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/gotestyourself/gotestyourself/assert"
is "github.com/gotestyourself/gotestyourself/assert/cmp"
)

func TestMaskSecretKeys(t *testing.T) {
Expand Down Expand Up @@ -53,6 +54,6 @@ func TestMaskSecretKeys(t *testing.T) {

for _, testcase := range tests {
maskSecretKeys(testcase.input, testcase.path)
assert.Equal(t, testcase.expected, testcase.input)
assert.Check(t, is.DeepEqual(testcase.expected, testcase.input))
}
}
21 changes: 11 additions & 10 deletions api/server/middleware/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import (
"testing"

"github.com/docker/docker/api/server/httputils"
"github.com/stretchr/testify/assert"
"github.com/gotestyourself/gotestyourself/assert"
is "github.com/gotestyourself/gotestyourself/assert/cmp"
"golang.org/x/net/context"
)

Expand All @@ -17,7 +18,7 @@ func TestVersionMiddlewareVersion(t *testing.T) {
expectedVersion := defaultVersion
handler := func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
v := httputils.VersionFromContext(ctx)
assert.Equal(t, expectedVersion, v)
assert.Check(t, is.Equal(expectedVersion, v))
return nil
}

Expand Down Expand Up @@ -56,17 +57,17 @@ func TestVersionMiddlewareVersion(t *testing.T) {
err := h(ctx, resp, req, map[string]string{"version": test.reqVersion})

if test.errString != "" {
assert.EqualError(t, err, test.errString)
assert.Check(t, is.Error(err, test.errString))
} else {
assert.NoError(t, err)
assert.Check(t, err)
}
}
}

func TestVersionMiddlewareWithErrorsReturnsHeaders(t *testing.T) {
handler := func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
v := httputils.VersionFromContext(ctx)
assert.NotEmpty(t, v)
assert.Check(t, len(v) != 0)
return nil
}

Expand All @@ -81,11 +82,11 @@ func TestVersionMiddlewareWithErrorsReturnsHeaders(t *testing.T) {

vars := map[string]string{"version": "0.1"}
err := h(ctx, resp, req, vars)
assert.Error(t, err)
assert.Check(t, is.ErrorContains(err, ""))

hdr := resp.Result().Header
assert.Contains(t, hdr.Get("Server"), "Docker/"+defaultVersion)
assert.Contains(t, hdr.Get("Server"), runtime.GOOS)
assert.Equal(t, hdr.Get("API-Version"), defaultVersion)
assert.Equal(t, hdr.Get("OSType"), runtime.GOOS)
assert.Check(t, is.Contains(hdr.Get("Server"), "Docker/"+defaultVersion))
assert.Check(t, is.Contains(hdr.Get("Server"), runtime.GOOS))
assert.Check(t, is.Equal(hdr.Get("API-Version"), defaultVersion))
assert.Check(t, is.Equal(hdr.Get("OSType"), runtime.GOOS))
}
15 changes: 7 additions & 8 deletions api/types/filters/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"errors"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/gotestyourself/gotestyourself/assert"
is "github.com/gotestyourself/gotestyourself/assert/cmp"
)

func TestParseArgs(t *testing.T) {
Expand All @@ -22,10 +22,10 @@ func TestParseArgs(t *testing.T) {

for i := range flagArgs {
args, err = ParseFlag(flagArgs[i], args)
require.NoError(t, err)
assert.NilError(t, err)
}
assert.Len(t, args.Get("created"), 1)
assert.Len(t, args.Get("image.name"), 2)
assert.Check(t, is.Len(args.Get("created"), 1))
assert.Check(t, is.Len(args.Get("image.name"), 2))
}

func TestParseArgsEdgeCase(t *testing.T) {
Expand Down Expand Up @@ -231,7 +231,7 @@ func TestArgsMatch(t *testing.T) {
}

for args, field := range matches {
assert.True(t, args.Match(field, source),
assert.Check(t, args.Match(field, source),
"Expected field %s to match %s", field, source)
}

Expand All @@ -255,8 +255,7 @@ func TestArgsMatch(t *testing.T) {
}

for args, field := range differs {
assert.False(t, args.Match(field, source),
"Expected field %s to not match %s", field, source)
assert.Check(t, !args.Match(field, source), "Expected field %s to not match %s", field, source)
}
}

Expand Down
17 changes: 9 additions & 8 deletions builder/dockerfile/buildargs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import (
"bytes"
"testing"

"github.com/stretchr/testify/assert"
"github.com/gotestyourself/gotestyourself/assert"
is "github.com/gotestyourself/gotestyourself/assert/cmp"
)

func strPtr(source string) *string {
Expand Down Expand Up @@ -39,7 +40,7 @@ func TestGetAllAllowed(t *testing.T) {
"ArgFromMeta": "frommeta1",
"ArgFromMetaOverridden": "fromdockerfile3",
}
assert.Equal(t, expected, all)
assert.Check(t, is.DeepEqual(expected, all))
}

func TestGetAllMeta(t *testing.T) {
Expand All @@ -61,7 +62,7 @@ func TestGetAllMeta(t *testing.T) {
"ArgOverriddenByOptions": "fromopt2",
"ArgNoDefaultInMetaFromOptions": "fromopt3",
}
assert.Equal(t, expected, all)
assert.Check(t, is.DeepEqual(expected, all))
}

func TestWarnOnUnusedBuildArgs(t *testing.T) {
Expand All @@ -80,7 +81,7 @@ func TestWarnOnUnusedBuildArgs(t *testing.T) {
assert.NotContains(t, out, "ThisArgIsUsed")
assert.NotContains(t, out, "HTTPS_PROXY")
assert.NotContains(t, out, "HTTP_PROXY")
assert.Contains(t, out, "ThisArgIsNotUsed")
assert.Check(t, is.Contains(out, "ThisArgIsNotUsed"))
}

func TestIsUnreferencedBuiltin(t *testing.T) {
Expand All @@ -93,8 +94,8 @@ func TestIsUnreferencedBuiltin(t *testing.T) {
buildArgs.AddArg("ThisArgIsUsed", nil)
buildArgs.AddArg("HTTPS_PROXY", nil)

assert.True(t, buildArgs.IsReferencedOrNotBuiltin("ThisArgIsUsed"))
assert.True(t, buildArgs.IsReferencedOrNotBuiltin("ThisArgIsNotUsed"))
assert.True(t, buildArgs.IsReferencedOrNotBuiltin("HTTPS_PROXY"))
assert.False(t, buildArgs.IsReferencedOrNotBuiltin("HTTP_PROXY"))
assert.Check(t, buildArgs.IsReferencedOrNotBuiltin("ThisArgIsUsed"))
assert.Check(t, buildArgs.IsReferencedOrNotBuiltin("ThisArgIsNotUsed"))
assert.Check(t, buildArgs.IsReferencedOrNotBuiltin("HTTPS_PROXY"))
assert.Check(t, !buildArgs.IsReferencedOrNotBuiltin("HTTP_PROXY"))
}
9 changes: 5 additions & 4 deletions builder/dockerfile/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import (
"testing"

"github.com/docker/docker/builder/dockerfile/parser"
"github.com/stretchr/testify/assert"
"github.com/gotestyourself/gotestyourself/assert"
is "github.com/gotestyourself/gotestyourself/assert/cmp"
)

func TestAddNodesForLabelOption(t *testing.T) {
dockerfile := "FROM scratch"
result, err := parser.Parse(strings.NewReader(dockerfile))
assert.NoError(t, err)
assert.Check(t, err)

labels := map[string]string{
"org.e": "cli-e",
Expand All @@ -27,8 +28,8 @@ func TestAddNodesForLabelOption(t *testing.T) {
"FROM scratch",
`LABEL "org.a"='cli-a' "org.b"='cli-b' "org.c"='cli-c' "org.d"='cli-d' "org.e"='cli-e'`,
}
assert.Len(t, nodes.Children, 2)
assert.Check(t, is.Len(nodes.Children, 2))
for i, v := range nodes.Children {
assert.Equal(t, expected[i], v.Original)
assert.Check(t, is.Equal(expected[i], v.Original))
}
}
9 changes: 5 additions & 4 deletions builder/dockerfile/copy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import (
"testing"

"github.com/docker/docker/pkg/containerfs"
"github.com/gotestyourself/gotestyourself/assert"
is "github.com/gotestyourself/gotestyourself/assert/cmp"
"github.com/gotestyourself/gotestyourself/fs"
"github.com/stretchr/testify/assert"
)

func TestIsExistingDirectory(t *testing.T) {
Expand Down Expand Up @@ -39,10 +40,10 @@ func TestIsExistingDirectory(t *testing.T) {

for _, testcase := range testcases {
result, err := isExistingDirectory(&copyEndpoint{driver: containerfs.NewLocalDriver(), path: testcase.path})
if !assert.NoError(t, err) {
if !assert.Check(t, err) {
continue
}
assert.Equal(t, testcase.expected, result, testcase.doc)
assert.Check(t, is.Equal(testcase.expected, result), testcase.doc)
}
}

Expand Down Expand Up @@ -142,6 +143,6 @@ func TestGetFilenameForDownload(t *testing.T) {
resp.Header.Add("Content-Disposition", testcase.disposition)
}
filename := getFilenameForDownload(testcase.path, &resp)
assert.Equal(t, testcase.expected, filename)
assert.Check(t, is.Equal(testcase.expected, filename))
}
}
Loading

0 comments on commit 6be0f70

Please sign in to comment.