Signed-off-by: Daniel Nephin <dnephin@docker.com>
| ... | ... |
@@ -2,6 +2,7 @@ package dockerfile // import "github.com/docker/docker/builder/dockerfile" |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 | 4 |
"bytes" |
| 5 |
+ "strings" |
|
| 5 | 6 |
"testing" |
| 6 | 7 |
|
| 7 | 8 |
"github.com/gotestyourself/gotestyourself/assert" |
| ... | ... |
@@ -78,9 +79,9 @@ func TestWarnOnUnusedBuildArgs(t *testing.T) {
|
| 78 | 78 |
buffer := new(bytes.Buffer) |
| 79 | 79 |
buildArgs.WarnOnUnusedBuildArgs(buffer) |
| 80 | 80 |
out := buffer.String() |
| 81 |
- assert.NotContains(t, out, "ThisArgIsUsed") |
|
| 82 |
- assert.NotContains(t, out, "HTTPS_PROXY") |
|
| 83 |
- assert.NotContains(t, out, "HTTP_PROXY") |
|
| 81 |
+ assert.Assert(t, !strings.Contains(out, "ThisArgIsUsed"), out) |
|
| 82 |
+ assert.Assert(t, !strings.Contains(out, "HTTPS_PROXY"), out) |
|
| 83 |
+ assert.Assert(t, !strings.Contains(out, "HTTP_PROXY"), out) |
|
| 84 | 84 |
assert.Check(t, is.Contains(out, "ThisArgIsNotUsed")) |
| 85 | 85 |
} |
| 86 | 86 |
|
| ... | ... |
@@ -3,6 +3,7 @@ package parser // import "github.com/docker/docker/builder/dockerfile/parser" |
| 3 | 3 |
import ( |
| 4 | 4 |
"testing" |
| 5 | 5 |
|
| 6 |
+ "github.com/google/go-cmp/cmp" |
|
| 6 | 7 |
"github.com/gotestyourself/gotestyourself/assert" |
| 7 | 8 |
is "github.com/gotestyourself/gotestyourself/assert/cmp" |
| 8 | 9 |
) |
| ... | ... |
@@ -16,9 +17,11 @@ func TestParseNameValOldFormat(t *testing.T) {
|
| 16 | 16 |
Value: "foo", |
| 17 | 17 |
Next: &Node{Value: "bar"},
|
| 18 | 18 |
} |
| 19 |
- assert.Check(t, is.DeepEqual(expected, node)) |
|
| 19 |
+ assert.DeepEqual(t, expected, node, cmpNodeOpt) |
|
| 20 | 20 |
} |
| 21 | 21 |
|
| 22 |
+var cmpNodeOpt = cmp.AllowUnexported(Node{})
|
|
| 23 |
+ |
|
| 22 | 24 |
func TestParseNameValNewFormat(t *testing.T) {
|
| 23 | 25 |
directive := Directive{}
|
| 24 | 26 |
node, err := parseNameVal("foo=bar thing=star", "LABEL", &directive)
|
| ... | ... |
@@ -36,7 +39,7 @@ func TestParseNameValNewFormat(t *testing.T) {
|
| 36 | 36 |
}, |
| 37 | 37 |
}, |
| 38 | 38 |
} |
| 39 |
- assert.Check(t, is.DeepEqual(expected, node)) |
|
| 39 |
+ assert.DeepEqual(t, expected, node, cmpNodeOpt) |
|
| 40 | 40 |
} |
| 41 | 41 |
|
| 42 | 42 |
func TestNodeFromLabels(t *testing.T) {
|
| ... | ... |
@@ -62,8 +65,7 @@ func TestNodeFromLabels(t *testing.T) {
|
| 62 | 62 |
} |
| 63 | 63 |
|
| 64 | 64 |
node := NodeFromLabels(labels) |
| 65 |
- assert.Check(t, is.DeepEqual(expected, node)) |
|
| 66 |
- |
|
| 65 |
+ assert.DeepEqual(t, expected, node, cmpNodeOpt) |
|
| 67 | 66 |
} |
| 68 | 67 |
|
| 69 | 68 |
func TestParseNameValWithoutVal(t *testing.T) {
|
| ... | ... |
@@ -13,6 +13,7 @@ import ( |
| 13 | 13 |
"strings" |
| 14 | 14 |
"testing" |
| 15 | 15 |
|
| 16 |
+ "github.com/google/go-cmp/cmp" |
|
| 16 | 17 |
"github.com/gotestyourself/gotestyourself/assert" |
| 17 | 18 |
is "github.com/gotestyourself/gotestyourself/assert/cmp" |
| 18 | 19 |
) |
| ... | ... |
@@ -20,35 +21,31 @@ import ( |
| 20 | 20 |
func TestParseRemoteURL(t *testing.T) {
|
| 21 | 21 |
dir, err := parseRemoteURL("git://github.com/user/repo.git")
|
| 22 | 22 |
assert.NilError(t, err) |
| 23 |
- assert.Check(t, len(dir) != 0) |
|
| 24 |
- assert.Check(t, is.DeepEqual(gitRepo{"git://github.com/user/repo.git", "master", ""}, dir))
|
|
| 23 |
+ assert.Check(t, is.DeepEqual(gitRepo{"git://github.com/user/repo.git", "master", ""}, dir, cmpGitRepoOpt))
|
|
| 25 | 24 |
|
| 26 | 25 |
dir, err = parseRemoteURL("git://github.com/user/repo.git#mybranch:mydir/mysubdir/")
|
| 27 | 26 |
assert.NilError(t, err) |
| 28 |
- assert.Check(t, len(dir) != 0) |
|
| 29 |
- assert.Check(t, is.DeepEqual(gitRepo{"git://github.com/user/repo.git", "mybranch", "mydir/mysubdir/"}, dir))
|
|
| 27 |
+ assert.Check(t, is.DeepEqual(gitRepo{"git://github.com/user/repo.git", "mybranch", "mydir/mysubdir/"}, dir, cmpGitRepoOpt))
|
|
| 30 | 28 |
|
| 31 | 29 |
dir, err = parseRemoteURL("https://github.com/user/repo.git")
|
| 32 | 30 |
assert.NilError(t, err) |
| 33 |
- assert.Check(t, len(dir) != 0) |
|
| 34 |
- assert.Check(t, is.DeepEqual(gitRepo{"https://github.com/user/repo.git", "master", ""}, dir))
|
|
| 31 |
+ assert.Check(t, is.DeepEqual(gitRepo{"https://github.com/user/repo.git", "master", ""}, dir, cmpGitRepoOpt))
|
|
| 35 | 32 |
|
| 36 | 33 |
dir, err = parseRemoteURL("https://github.com/user/repo.git#mybranch:mydir/mysubdir/")
|
| 37 | 34 |
assert.NilError(t, err) |
| 38 |
- assert.Check(t, len(dir) != 0) |
|
| 39 |
- assert.Check(t, is.DeepEqual(gitRepo{"https://github.com/user/repo.git", "mybranch", "mydir/mysubdir/"}, dir))
|
|
| 35 |
+ assert.Check(t, is.DeepEqual(gitRepo{"https://github.com/user/repo.git", "mybranch", "mydir/mysubdir/"}, dir, cmpGitRepoOpt))
|
|
| 40 | 36 |
|
| 41 | 37 |
dir, err = parseRemoteURL("git@github.com:user/repo.git")
|
| 42 | 38 |
assert.NilError(t, err) |
| 43 |
- assert.Check(t, len(dir) != 0) |
|
| 44 |
- assert.Check(t, is.DeepEqual(gitRepo{"git@github.com:user/repo.git", "master", ""}, dir))
|
|
| 39 |
+ assert.Check(t, is.DeepEqual(gitRepo{"git@github.com:user/repo.git", "master", ""}, dir, cmpGitRepoOpt))
|
|
| 45 | 40 |
|
| 46 | 41 |
dir, err = parseRemoteURL("git@github.com:user/repo.git#mybranch:mydir/mysubdir/")
|
| 47 | 42 |
assert.NilError(t, err) |
| 48 |
- assert.Check(t, len(dir) != 0) |
|
| 49 |
- assert.Check(t, is.DeepEqual(gitRepo{"git@github.com:user/repo.git", "mybranch", "mydir/mysubdir/"}, dir))
|
|
| 43 |
+ assert.Check(t, is.DeepEqual(gitRepo{"git@github.com:user/repo.git", "mybranch", "mydir/mysubdir/"}, dir, cmpGitRepoOpt))
|
|
| 50 | 44 |
} |
| 51 | 45 |
|
| 46 |
+var cmpGitRepoOpt = cmp.AllowUnexported(gitRepo{})
|
|
| 47 |
+ |
|
| 52 | 48 |
func TestCloneArgsSmartHttp(t *testing.T) {
|
| 53 | 49 |
mux := http.NewServeMux() |
| 54 | 50 |
server := httptest.NewServer(mux) |
| ... | ... |
@@ -89,8 +89,7 @@ func TestNewEnvClient(t *testing.T) {
|
| 89 | 89 |
env.PatchAll(t, c.envs) |
| 90 | 90 |
apiclient, err := NewEnvClient() |
| 91 | 91 |
if c.expectedError != "" {
|
| 92 |
- assert.Check(t, is.ErrorContains(err, ""), c.doc) |
|
| 93 |
- assert.Check(t, is.Equal(c.expectedError, err.Error()), c.doc) |
|
| 92 |
+ assert.Check(t, is.Error(err, c.expectedError), c.doc) |
|
| 94 | 93 |
} else {
|
| 95 | 94 |
assert.Check(t, err, c.doc) |
| 96 | 95 |
version := apiclient.ClientVersion() |
| ... | ... |
@@ -100,7 +99,7 @@ func TestNewEnvClient(t *testing.T) {
|
| 100 | 100 |
if c.envs["DOCKER_TLS_VERIFY"] != "" {
|
| 101 | 101 |
// pedantic checking that this is handled correctly |
| 102 | 102 |
tr := apiclient.client.Transport.(*http.Transport) |
| 103 |
- assert.Check(t, tr.TLSClientConfig != nil, c.doc) |
|
| 103 |
+ assert.Assert(t, tr.TLSClientConfig != nil, c.doc) |
|
| 104 | 104 |
assert.Check(t, is.Equal(tr.TLSClientConfig.InsecureSkipVerify, false), c.doc) |
| 105 | 105 |
} |
| 106 | 106 |
} |
| ... | ... |
@@ -298,7 +297,7 @@ func TestClientRedirect(t *testing.T) {
|
| 298 | 298 |
|
| 299 | 299 |
cases := []struct {
|
| 300 | 300 |
httpMethod string |
| 301 |
- expectedErr error |
|
| 301 |
+ expectedErr *url.Error |
|
| 302 | 302 |
statusCode int |
| 303 | 303 |
}{
|
| 304 | 304 |
{http.MethodGet, nil, 301},
|
| ... | ... |
@@ -311,7 +310,13 @@ func TestClientRedirect(t *testing.T) {
|
| 311 | 311 |
req, err := http.NewRequest(tc.httpMethod, "/redirectme", nil) |
| 312 | 312 |
assert.Check(t, err) |
| 313 | 313 |
resp, err := client.Do(req) |
| 314 |
- assert.Check(t, is.DeepEqual(tc.expectedErr, err)) |
|
| 315 | 314 |
assert.Check(t, is.Equal(tc.statusCode, resp.StatusCode)) |
| 315 |
+ if tc.expectedErr == nil {
|
|
| 316 |
+ assert.Check(t, is.Nil(err)) |
|
| 317 |
+ } else {
|
|
| 318 |
+ urlError, ok := err.(*url.Error) |
|
| 319 |
+ assert.Assert(t, ok, "%T is not *url.Error", err) |
|
| 320 |
+ assert.Check(t, is.Equal(*tc.expectedErr, *urlError)) |
|
| 321 |
+ } |
|
| 316 | 322 |
} |
| 317 | 323 |
} |
| ... | ... |
@@ -15,7 +15,7 @@ import ( |
| 15 | 15 |
"github.com/docker/docker/daemon/graphdriver" |
| 16 | 16 |
"github.com/docker/docker/daemon/graphdriver/quota" |
| 17 | 17 |
"github.com/docker/docker/pkg/stringid" |
| 18 |
- "github.com/docker/go-units" |
|
| 18 |
+ units "github.com/docker/go-units" |
|
| 19 | 19 |
"github.com/gotestyourself/gotestyourself/assert" |
| 20 | 20 |
is "github.com/gotestyourself/gotestyourself/assert/cmp" |
| 21 | 21 |
"golang.org/x/sys/unix" |
| ... | ... |
@@ -148,5 +148,5 @@ func testRetrieveQuota(t *testing.T, ctrl *Control, homeDir, testDir, testSubDir |
| 148 | 148 |
|
| 149 | 149 |
var q Quota |
| 150 | 150 |
assert.NilError(t, ctrl.GetQuota(testSubDir, &q)) |
| 151 |
- assert.Check(t, is.Equal(testQuotaSize, q.Size)) |
|
| 151 |
+ assert.Check(t, is.Equal(uint64(testQuotaSize), q.Size)) |
|
| 152 | 152 |
} |
| ... | ... |
@@ -121,7 +121,7 @@ func TestAdapterReadLogs(t *testing.T) {
|
| 121 | 121 |
} |
| 122 | 122 |
|
| 123 | 123 |
lr, ok := l.(LogReader) |
| 124 |
- assert.Check(t, ok != nil) |
|
| 124 |
+ assert.Check(t, ok, "Logger does not implement LogReader") |
|
| 125 | 125 |
|
| 126 | 126 |
lw := lr.ReadLogs(ReadConfig{})
|
| 127 | 127 |
|
| ... | ... |
@@ -158,7 +158,7 @@ func TestAdapterReadLogs(t *testing.T) {
|
| 158 | 158 |
|
| 159 | 159 |
select {
|
| 160 | 160 |
case msg, ok := <-lw.Msg: |
| 161 |
- assert.Check(t, ok != nil, "message channel unexpectedly closed") |
|
| 161 |
+ assert.Check(t, ok, "message channel unexpectedly closed") |
|
| 162 | 162 |
testMessageEqual(t, &x, msg) |
| 163 | 163 |
case <-time.After(10 * time.Second): |
| 164 | 164 |
t.Fatal("timeout reading logs")
|
| ... | ... |
@@ -3,6 +3,7 @@ package jsonlog // import "github.com/docker/docker/daemon/logger/jsonfilelog/js |
| 3 | 3 |
import ( |
| 4 | 4 |
"bytes" |
| 5 | 5 |
"encoding/json" |
| 6 |
+ "fmt" |
|
| 6 | 7 |
"regexp" |
| 7 | 8 |
"testing" |
| 8 | 9 |
"time" |
| ... | ... |
@@ -35,7 +36,16 @@ func TestJSONLogsMarshalJSONBuf(t *testing.T) {
|
| 35 | 35 |
var buf bytes.Buffer |
| 36 | 36 |
err := jsonLog.MarshalJSONBuf(&buf) |
| 37 | 37 |
assert.NilError(t, err) |
| 38 |
- assert.Regexp(t, regexp.MustCompile(expression), buf.String()) |
|
| 39 |
- assert.Check(t, json.Unmarshal(buf.Bytes(), &map[string]interface{}{}))
|
|
| 38 |
+ |
|
| 39 |
+ assert.Assert(t, regexP(buf.String(), expression)) |
|
| 40 |
+ assert.NilError(t, json.Unmarshal(buf.Bytes(), &map[string]interface{}{}))
|
|
| 41 |
+ } |
|
| 42 |
+} |
|
| 43 |
+ |
|
| 44 |
+func regexP(value string, pattern string) func() (bool, string) {
|
|
| 45 |
+ return func() (bool, string) {
|
|
| 46 |
+ re := regexp.MustCompile(pattern) |
|
| 47 |
+ msg := fmt.Sprintf("%q did not match pattern %q", value, pattern)
|
|
| 48 |
+ return re.MatchString(value), msg |
|
| 40 | 49 |
} |
| 41 | 50 |
} |
| ... | ... |
@@ -9,6 +9,7 @@ import ( |
| 9 | 9 |
|
| 10 | 10 |
"github.com/docker/docker/api/types/container" |
| 11 | 11 |
"github.com/docker/docker/layer" |
| 12 |
+ "github.com/google/go-cmp/cmp" |
|
| 12 | 13 |
"github.com/gotestyourself/gotestyourself/assert" |
| 13 | 14 |
is "github.com/gotestyourself/gotestyourself/assert/cmp" |
| 14 | 15 |
) |
| ... | ... |
@@ -119,6 +120,6 @@ func TestNewChildImageFromImageWithRootFS(t *testing.T) {
|
| 119 | 119 |
assert.Check(t, is.Len(newImage.History, 2)) |
| 120 | 120 |
assert.Check(t, is.Equal(childConfig.Comment, newImage.History[1].Comment)) |
| 121 | 121 |
|
| 122 |
- // RootFS should be copied not mutated |
|
| 123 |
- assert.Check(t, parent.RootFS.DiffIDs != newImage.RootFS.DiffIDs) |
|
| 122 |
+ assert.Check(t, !cmp.Equal(parent.RootFS.DiffIDs, newImage.RootFS.DiffIDs), |
|
| 123 |
+ "RootFS should be copied not mutated") |
|
| 124 | 124 |
} |
| ... | ... |
@@ -5,10 +5,9 @@ import ( |
| 5 | 5 |
"runtime" |
| 6 | 6 |
"testing" |
| 7 | 7 |
|
| 8 |
- "github.com/docker/docker/internal/testutil" |
|
| 9 | 8 |
"github.com/docker/docker/layer" |
| 10 | 9 |
"github.com/gotestyourself/gotestyourself/assert" |
| 11 |
- is "github.com/gotestyourself/gotestyourself/assert/cmp" |
|
| 10 |
+ "github.com/gotestyourself/gotestyourself/assert/cmp" |
|
| 12 | 11 |
"github.com/opencontainers/go-digest" |
| 13 | 12 |
) |
| 14 | 13 |
|
| ... | ... |
@@ -17,57 +16,57 @@ func TestRestore(t *testing.T) {
|
| 17 | 17 |
defer cleanup() |
| 18 | 18 |
|
| 19 | 19 |
id1, err := fs.Set([]byte(`{"comment": "abc", "rootfs": {"type": "layers"}}`))
|
| 20 |
- assert.Check(t, err) |
|
| 20 |
+ assert.NilError(t, err) |
|
| 21 | 21 |
|
| 22 | 22 |
_, err = fs.Set([]byte(`invalid`)) |
| 23 |
- assert.Check(t, err) |
|
| 23 |
+ assert.NilError(t, err) |
|
| 24 | 24 |
|
| 25 | 25 |
id2, err := fs.Set([]byte(`{"comment": "def", "rootfs": {"type": "layers", "diff_ids": ["2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae"]}}`))
|
| 26 |
- assert.Check(t, err) |
|
| 26 |
+ assert.NilError(t, err) |
|
| 27 | 27 |
|
| 28 | 28 |
err = fs.SetMetadata(id2, "parent", []byte(id1)) |
| 29 |
- assert.Check(t, err) |
|
| 29 |
+ assert.NilError(t, err) |
|
| 30 | 30 |
|
| 31 | 31 |
mlgrMap := make(map[string]LayerGetReleaser) |
| 32 | 32 |
mlgrMap[runtime.GOOS] = &mockLayerGetReleaser{}
|
| 33 | 33 |
is, err := NewImageStore(fs, mlgrMap) |
| 34 |
- assert.Check(t, err) |
|
| 34 |
+ assert.NilError(t, err) |
|
| 35 | 35 |
|
| 36 |
- assert.Check(t, is.Len(is.Map(), 2)) |
|
| 36 |
+ assert.Check(t, cmp.Len(is.Map(), 2)) |
|
| 37 | 37 |
|
| 38 | 38 |
img1, err := is.Get(ID(id1)) |
| 39 |
- assert.Check(t, err) |
|
| 40 |
- assert.Check(t, is.Equal(ID(id1), img1.computedID)) |
|
| 41 |
- assert.Check(t, is.Equal(string(id1), img1.computedID.String())) |
|
| 39 |
+ assert.NilError(t, err) |
|
| 40 |
+ assert.Check(t, cmp.Equal(ID(id1), img1.computedID)) |
|
| 41 |
+ assert.Check(t, cmp.Equal(string(id1), img1.computedID.String())) |
|
| 42 | 42 |
|
| 43 | 43 |
img2, err := is.Get(ID(id2)) |
| 44 |
- assert.Check(t, err) |
|
| 45 |
- assert.Check(t, is.Equal("abc", img1.Comment))
|
|
| 46 |
- assert.Check(t, is.Equal("def", img2.Comment))
|
|
| 44 |
+ assert.NilError(t, err) |
|
| 45 |
+ assert.Check(t, cmp.Equal("abc", img1.Comment))
|
|
| 46 |
+ assert.Check(t, cmp.Equal("def", img2.Comment))
|
|
| 47 | 47 |
|
| 48 | 48 |
_, err = is.GetParent(ID(id1)) |
| 49 |
- testutil.ErrorContains(t, err, "failed to read metadata") |
|
| 49 |
+ assert.ErrorContains(t, err, "failed to read metadata") |
|
| 50 | 50 |
|
| 51 | 51 |
p, err := is.GetParent(ID(id2)) |
| 52 |
- assert.Check(t, err) |
|
| 53 |
- assert.Check(t, is.Equal(ID(id1), p)) |
|
| 52 |
+ assert.NilError(t, err) |
|
| 53 |
+ assert.Check(t, cmp.Equal(ID(id1), p)) |
|
| 54 | 54 |
|
| 55 | 55 |
children := is.Children(ID(id1)) |
| 56 |
- assert.Check(t, is.Len(children, 1)) |
|
| 57 |
- assert.Check(t, is.Equal(ID(id2), children[0])) |
|
| 58 |
- assert.Check(t, is.Len(is.Heads(), 1)) |
|
| 56 |
+ assert.Check(t, cmp.Len(children, 1)) |
|
| 57 |
+ assert.Check(t, cmp.Equal(ID(id2), children[0])) |
|
| 58 |
+ assert.Check(t, cmp.Len(is.Heads(), 1)) |
|
| 59 | 59 |
|
| 60 | 60 |
sid1, err := is.Search(string(id1)[:10]) |
| 61 |
- assert.Check(t, err) |
|
| 62 |
- assert.Check(t, is.Equal(ID(id1), sid1)) |
|
| 61 |
+ assert.NilError(t, err) |
|
| 62 |
+ assert.Check(t, cmp.Equal(ID(id1), sid1)) |
|
| 63 | 63 |
|
| 64 | 64 |
sid1, err = is.Search(digest.Digest(id1).Hex()[:6]) |
| 65 |
- assert.Check(t, err) |
|
| 66 |
- assert.Check(t, is.Equal(ID(id1), sid1)) |
|
| 65 |
+ assert.NilError(t, err) |
|
| 66 |
+ assert.Check(t, cmp.Equal(ID(id1), sid1)) |
|
| 67 | 67 |
|
| 68 | 68 |
invalidPattern := digest.Digest(id1).Hex()[1:6] |
| 69 | 69 |
_, err = is.Search(invalidPattern) |
| 70 |
- testutil.ErrorContains(t, err, "No such image") |
|
| 70 |
+ assert.ErrorContains(t, err, "No such image") |
|
| 71 | 71 |
} |
| 72 | 72 |
|
| 73 | 73 |
func TestAddDelete(t *testing.T) {
|
| ... | ... |
@@ -75,34 +74,34 @@ func TestAddDelete(t *testing.T) {
|
| 75 | 75 |
defer cleanup() |
| 76 | 76 |
|
| 77 | 77 |
id1, err := is.Create([]byte(`{"comment": "abc", "rootfs": {"type": "layers", "diff_ids": ["2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae"]}}`))
|
| 78 |
- assert.Check(t, err) |
|
| 79 |
- assert.Check(t, is.Equal(ID("sha256:8d25a9c45df515f9d0fe8e4a6b1c64dd3b965a84790ddbcc7954bb9bc89eb993"), id1))
|
|
| 78 |
+ assert.NilError(t, err) |
|
| 79 |
+ assert.Check(t, cmp.Equal(ID("sha256:8d25a9c45df515f9d0fe8e4a6b1c64dd3b965a84790ddbcc7954bb9bc89eb993"), id1))
|
|
| 80 | 80 |
|
| 81 | 81 |
img, err := is.Get(id1) |
| 82 |
- assert.Check(t, err) |
|
| 83 |
- assert.Check(t, is.Equal("abc", img.Comment))
|
|
| 82 |
+ assert.NilError(t, err) |
|
| 83 |
+ assert.Check(t, cmp.Equal("abc", img.Comment))
|
|
| 84 | 84 |
|
| 85 | 85 |
id2, err := is.Create([]byte(`{"comment": "def", "rootfs": {"type": "layers", "diff_ids": ["2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae"]}}`))
|
| 86 |
- assert.Check(t, err) |
|
| 86 |
+ assert.NilError(t, err) |
|
| 87 | 87 |
|
| 88 | 88 |
err = is.SetParent(id2, id1) |
| 89 |
- assert.Check(t, err) |
|
| 89 |
+ assert.NilError(t, err) |
|
| 90 | 90 |
|
| 91 | 91 |
pid1, err := is.GetParent(id2) |
| 92 |
- assert.Check(t, err) |
|
| 93 |
- assert.Check(t, is.Equal(pid1, id1)) |
|
| 92 |
+ assert.NilError(t, err) |
|
| 93 |
+ assert.Check(t, cmp.Equal(pid1, id1)) |
|
| 94 | 94 |
|
| 95 | 95 |
_, err = is.Delete(id1) |
| 96 |
- assert.Check(t, err) |
|
| 96 |
+ assert.NilError(t, err) |
|
| 97 | 97 |
|
| 98 | 98 |
_, err = is.Get(id1) |
| 99 |
- testutil.ErrorContains(t, err, "failed to get digest") |
|
| 99 |
+ assert.ErrorContains(t, err, "failed to get digest") |
|
| 100 | 100 |
|
| 101 | 101 |
_, err = is.Get(id2) |
| 102 |
- assert.Check(t, err) |
|
| 102 |
+ assert.NilError(t, err) |
|
| 103 | 103 |
|
| 104 | 104 |
_, err = is.GetParent(id2) |
| 105 |
- testutil.ErrorContains(t, err, "failed to read metadata") |
|
| 105 |
+ assert.ErrorContains(t, err, "failed to read metadata") |
|
| 106 | 106 |
} |
| 107 | 107 |
|
| 108 | 108 |
func TestSearchAfterDelete(t *testing.T) {
|
| ... | ... |
@@ -110,17 +109,17 @@ func TestSearchAfterDelete(t *testing.T) {
|
| 110 | 110 |
defer cleanup() |
| 111 | 111 |
|
| 112 | 112 |
id, err := is.Create([]byte(`{"comment": "abc", "rootfs": {"type": "layers"}}`))
|
| 113 |
- assert.Check(t, err) |
|
| 113 |
+ assert.NilError(t, err) |
|
| 114 | 114 |
|
| 115 | 115 |
id1, err := is.Search(string(id)[:15]) |
| 116 |
- assert.Check(t, err) |
|
| 117 |
- assert.Check(t, is.Equal(id1, id)) |
|
| 116 |
+ assert.NilError(t, err) |
|
| 117 |
+ assert.Check(t, cmp.Equal(id1, id)) |
|
| 118 | 118 |
|
| 119 | 119 |
_, err = is.Delete(id) |
| 120 |
- assert.Check(t, err) |
|
| 120 |
+ assert.NilError(t, err) |
|
| 121 | 121 |
|
| 122 | 122 |
_, err = is.Search(string(id)[:15]) |
| 123 |
- testutil.ErrorContains(t, err, "No such image") |
|
| 123 |
+ assert.ErrorContains(t, err, "No such image") |
|
| 124 | 124 |
} |
| 125 | 125 |
|
| 126 | 126 |
func TestParentReset(t *testing.T) {
|
| ... | ... |
@@ -128,20 +127,20 @@ func TestParentReset(t *testing.T) {
|
| 128 | 128 |
defer cleanup() |
| 129 | 129 |
|
| 130 | 130 |
id, err := is.Create([]byte(`{"comment": "abc1", "rootfs": {"type": "layers"}}`))
|
| 131 |
- assert.Check(t, err) |
|
| 131 |
+ assert.NilError(t, err) |
|
| 132 | 132 |
|
| 133 | 133 |
id2, err := is.Create([]byte(`{"comment": "abc2", "rootfs": {"type": "layers"}}`))
|
| 134 |
- assert.Check(t, err) |
|
| 134 |
+ assert.NilError(t, err) |
|
| 135 | 135 |
|
| 136 | 136 |
id3, err := is.Create([]byte(`{"comment": "abc3", "rootfs": {"type": "layers"}}`))
|
| 137 |
- assert.Check(t, err) |
|
| 137 |
+ assert.NilError(t, err) |
|
| 138 | 138 |
|
| 139 | 139 |
assert.Check(t, is.SetParent(id, id2)) |
| 140 |
- assert.Check(t, is.Len(is.Children(id2), 1)) |
|
| 140 |
+ assert.Check(t, cmp.Len(is.Children(id2), 1)) |
|
| 141 | 141 |
|
| 142 | 142 |
assert.Check(t, is.SetParent(id, id3)) |
| 143 |
- assert.Check(t, is.Len(is.Children(id2), 0)) |
|
| 144 |
- assert.Check(t, is.Len(is.Children(id3), 1)) |
|
| 143 |
+ assert.Check(t, cmp.Len(is.Children(id2), 0)) |
|
| 144 |
+ assert.Check(t, cmp.Len(is.Children(id3), 1)) |
|
| 145 | 145 |
} |
| 146 | 146 |
|
| 147 | 147 |
func defaultImageStore(t *testing.T) (Store, func()) {
|
| ... | ... |
@@ -150,7 +149,7 @@ func defaultImageStore(t *testing.T) (Store, func()) {
|
| 150 | 150 |
mlgrMap := make(map[string]LayerGetReleaser) |
| 151 | 151 |
mlgrMap[runtime.GOOS] = &mockLayerGetReleaser{}
|
| 152 | 152 |
store, err := NewImageStore(fsBackend, mlgrMap) |
| 153 |
- assert.Check(t, err) |
|
| 153 |
+ assert.NilError(t, err) |
|
| 154 | 154 |
|
| 155 | 155 |
return store, cleanup |
| 156 | 156 |
} |
| ... | ... |
@@ -160,17 +159,17 @@ func TestGetAndSetLastUpdated(t *testing.T) {
|
| 160 | 160 |
defer cleanup() |
| 161 | 161 |
|
| 162 | 162 |
id, err := store.Create([]byte(`{"comment": "abc1", "rootfs": {"type": "layers"}}`))
|
| 163 |
- assert.Check(t, err) |
|
| 163 |
+ assert.NilError(t, err) |
|
| 164 | 164 |
|
| 165 | 165 |
updated, err := store.GetLastUpdated(id) |
| 166 |
- assert.Check(t, err) |
|
| 167 |
- assert.Check(t, is.Equal(updated.IsZero(), true)) |
|
| 166 |
+ assert.NilError(t, err) |
|
| 167 |
+ assert.Check(t, cmp.Equal(updated.IsZero(), true)) |
|
| 168 | 168 |
|
| 169 | 169 |
assert.Check(t, store.SetLastUpdated(id)) |
| 170 | 170 |
|
| 171 | 171 |
updated, err = store.GetLastUpdated(id) |
| 172 |
- assert.Check(t, err) |
|
| 173 |
- assert.Check(t, is.Equal(updated.IsZero(), false)) |
|
| 172 |
+ assert.NilError(t, err) |
|
| 173 |
+ assert.Check(t, cmp.Equal(updated.IsZero(), false)) |
|
| 174 | 174 |
} |
| 175 | 175 |
|
| 176 | 176 |
func TestStoreLen(t *testing.T) {
|
| ... | ... |
@@ -8,6 +8,7 @@ import ( |
| 8 | 8 |
|
| 9 | 9 |
"github.com/docker/docker/integration-cli/daemon" |
| 10 | 10 |
"github.com/docker/docker/integration-cli/environment" |
| 11 |
+ "github.com/gotestyourself/gotestyourself/assert" |
|
| 11 | 12 |
"github.com/gotestyourself/gotestyourself/icmd" |
| 12 | 13 |
"github.com/pkg/errors" |
| 13 | 14 |
) |
| ... | ... |
@@ -24,6 +25,7 @@ func SetTestEnvironment(env *environment.Execution) {
|
| 24 | 24 |
type CmdOperator func(*icmd.Cmd) func() |
| 25 | 25 |
|
| 26 | 26 |
type testingT interface {
|
| 27 |
+ assert.TestingT |
|
| 27 | 28 |
Fatal(args ...interface{})
|
| 28 | 29 |
Fatalf(string, ...interface{})
|
| 29 | 30 |
} |
| ... | ... |
@@ -298,7 +298,7 @@ COPY bar /` |
| 298 | 298 |
_, err = io.Copy(out, resp.Body) |
| 299 | 299 |
resp.Body.Close() |
| 300 | 300 |
assert.NilError(t, err) |
| 301 |
- require.NotContains(t, out.String(), "Using cache") |
|
| 301 |
+ assert.Assert(t, !strings.Contains(out.String(), "Using cache")) |
|
| 302 | 302 |
} |
| 303 | 303 |
|
| 304 | 304 |
// docker/for-linux#135 |
| ... | ... |
@@ -10,7 +10,6 @@ import ( |
| 10 | 10 |
"github.com/docker/docker/integration/internal/request" |
| 11 | 11 |
"github.com/docker/docker/pkg/archive" |
| 12 | 12 |
"github.com/gotestyourself/gotestyourself/assert" |
| 13 |
- is "github.com/gotestyourself/gotestyourself/assert/cmp" |
|
| 14 | 13 |
"github.com/gotestyourself/gotestyourself/poll" |
| 15 | 14 |
) |
| 16 | 15 |
|
| ... | ... |
@@ -39,5 +38,5 @@ func TestDiff(t *testing.T) {
|
| 39 | 39 |
|
| 40 | 40 |
items, err := client.ContainerDiff(ctx, cID) |
| 41 | 41 |
assert.NilError(t, err) |
| 42 |
- assert.Check(t, is.DeepEqual(expected, items)) |
|
| 42 |
+ assert.DeepEqual(t, expected, items) |
|
| 43 | 43 |
} |
| ... | ... |
@@ -46,10 +46,10 @@ func TestServiceWithPredefinedNetwork(t *testing.T) {
|
| 46 | 46 |
poll.WaitOn(t, serviceRunningCount(client, serviceID, instances), pollSettings) |
| 47 | 47 |
|
| 48 | 48 |
_, _, err = client.ServiceInspectWithRaw(context.Background(), serviceID, types.ServiceInspectOptions{})
|
| 49 |
- require.NoError(t, err) |
|
| 49 |
+ assert.NilError(t, err) |
|
| 50 | 50 |
|
| 51 | 51 |
err = client.ServiceRemove(context.Background(), serviceID) |
| 52 |
- require.NoError(t, err) |
|
| 52 |
+ assert.NilError(t, err) |
|
| 53 | 53 |
|
| 54 | 54 |
poll.WaitOn(t, serviceIsRemoved(client, serviceID), pollSettings) |
| 55 | 55 |
poll.WaitOn(t, noTasks(client), pollSettings) |
| ... | ... |
@@ -64,7 +64,7 @@ func TestServiceWithIngressNetwork(t *testing.T) {
|
| 64 | 64 |
defer d.Stop(t) |
| 65 | 65 |
|
| 66 | 66 |
client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) |
| 67 |
- require.NoError(t, err) |
|
| 67 |
+ assert.NilError(t, err) |
|
| 68 | 68 |
|
| 69 | 69 |
pollSettings := func(config *poll.Settings) {
|
| 70 | 70 |
if runtime.GOARCH == "arm64" || runtime.GOARCH == "arm" {
|
| ... | ... |
@@ -95,7 +95,7 @@ func TestServiceWithIngressNetwork(t *testing.T) {
|
| 95 | 95 |
serviceResp, err := client.ServiceCreate(context.Background(), serviceSpec, types.ServiceCreateOptions{
|
| 96 | 96 |
QueryRegistry: false, |
| 97 | 97 |
}) |
| 98 |
- require.NoError(t, err) |
|
| 98 |
+ assert.NilError(t, err) |
|
| 99 | 99 |
|
| 100 | 100 |
serviceID := serviceResp.ID |
| 101 | 101 |
poll.WaitOn(t, serviceRunningCount(client, serviceID, instances), pollSettings) |
| ... | ... |
@@ -115,11 +115,11 @@ func TestServiceWithIngressNetwork(t *testing.T) {
|
| 115 | 115 |
Verbose: true, |
| 116 | 116 |
Scope: "swarm", |
| 117 | 117 |
}) |
| 118 |
- require.NoError(t, err, "Ingress network was removed after removing service!") |
|
| 119 |
- require.NotZero(t, len(netInfo.Containers), "No load balancing endpoints in ingress network") |
|
| 120 |
- require.NotZero(t, len(netInfo.Peers), "No peers (including self) in ingress network") |
|
| 118 |
+ assert.NilError(t, err, "Ingress network was removed after removing service!") |
|
| 119 |
+ assert.Assert(t, len(netInfo.Containers) != 0, "No load balancing endpoints in ingress network") |
|
| 120 |
+ assert.Assert(t, len(netInfo.Peers) != 0, "No peers (including self) in ingress network") |
|
| 121 | 121 |
_, ok := netInfo.Containers["ingress-sbox"] |
| 122 |
- require.True(t, ok, "ingress-sbox not present in ingress network") |
|
| 122 |
+ assert.Assert(t, ok, "ingress-sbox not present in ingress network") |
|
| 123 | 123 |
} |
| 124 | 124 |
|
| 125 | 125 |
func serviceRunningCount(client client.ServiceAPIClient, serviceID string, instances uint64) func(log poll.LogT) poll.Result {
|
| ... | ... |
@@ -10,6 +10,7 @@ import ( |
| 10 | 10 |
swarmtypes "github.com/docker/docker/api/types/swarm" |
| 11 | 11 |
"github.com/docker/docker/client" |
| 12 | 12 |
"github.com/docker/docker/integration/internal/swarm" |
| 13 |
+ "github.com/google/go-cmp/cmp" |
|
| 13 | 14 |
"github.com/gotestyourself/gotestyourself/assert" |
| 14 | 15 |
is "github.com/gotestyourself/gotestyourself/assert/cmp" |
| 15 | 16 |
"github.com/gotestyourself/gotestyourself/poll" |
| ... | ... |
@@ -18,14 +19,14 @@ import ( |
| 18 | 18 |
) |
| 19 | 19 |
|
| 20 | 20 |
func TestInspect(t *testing.T) {
|
| 21 |
- skip.IfCondition(t, testEnv.IsRemoteDaemon()) |
|
| 21 |
+ skip.If(t, testEnv.IsRemoteDaemon()) |
|
| 22 | 22 |
defer setupTest(t)() |
| 23 | 23 |
d := swarm.NewSwarm(t, testEnv) |
| 24 | 24 |
defer d.Stop(t) |
| 25 | 25 |
client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) |
| 26 | 26 |
assert.NilError(t, err) |
| 27 | 27 |
|
| 28 |
- var before = time.Now() |
|
| 28 |
+ var now = time.Now() |
|
| 29 | 29 |
var instances uint64 = 2 |
| 30 | 30 |
serviceSpec := fullSwarmServiceSpec("test-service-inspect", instances)
|
| 31 | 31 |
|
| ... | ... |
@@ -40,11 +41,36 @@ func TestInspect(t *testing.T) {
|
| 40 | 40 |
|
| 41 | 41 |
service, _, err := client.ServiceInspectWithRaw(ctx, id, types.ServiceInspectOptions{})
|
| 42 | 42 |
assert.NilError(t, err) |
| 43 |
- assert.Check(t, is.DeepEqual(serviceSpec, service.Spec)) |
|
| 44 |
- assert.Check(t, is.Equal(uint64(11), service.Meta.Version.Index)) |
|
| 45 |
- assert.Check(t, is.Equal(id, service.ID)) |
|
| 46 |
- assert.WithinDuration(t, before, service.CreatedAt, 30*time.Second) |
|
| 47 |
- assert.WithinDuration(t, before, service.UpdatedAt, 30*time.Second) |
|
| 43 |
+ |
|
| 44 |
+ expected := swarmtypes.Service{
|
|
| 45 |
+ ID: id, |
|
| 46 |
+ Spec: serviceSpec, |
|
| 47 |
+ Meta: swarmtypes.Meta{
|
|
| 48 |
+ Version: swarmtypes.Version{Index: uint64(11)},
|
|
| 49 |
+ CreatedAt: now, |
|
| 50 |
+ UpdatedAt: now, |
|
| 51 |
+ }, |
|
| 52 |
+ } |
|
| 53 |
+ assert.Check(t, is.DeepEqual(service, expected, cmpServiceOpts())) |
|
| 54 |
+} |
|
| 55 |
+ |
|
| 56 |
+// TODO: use helpers from gotestyourself/assert/opt when available |
|
| 57 |
+func cmpServiceOpts() cmp.Option {
|
|
| 58 |
+ const threshold = 20 * time.Second |
|
| 59 |
+ |
|
| 60 |
+ metaTimeFields := func(path cmp.Path) bool {
|
|
| 61 |
+ switch path.String() {
|
|
| 62 |
+ case "Meta.CreatedAt", "Meta.UpdatedAt": |
|
| 63 |
+ return true |
|
| 64 |
+ } |
|
| 65 |
+ return false |
|
| 66 |
+ } |
|
| 67 |
+ withinThreshold := cmp.Comparer(func(x, y time.Time) bool {
|
|
| 68 |
+ delta := x.Sub(y) |
|
| 69 |
+ return delta < threshold && delta > -threshold |
|
| 70 |
+ }) |
|
| 71 |
+ |
|
| 72 |
+ return cmp.FilterPath(metaTimeFields, withinThreshold) |
|
| 48 | 73 |
} |
| 49 | 74 |
|
| 50 | 75 |
func fullSwarmServiceSpec(name string, replicas uint64) swarmtypes.ServiceSpec {
|
| ... | ... |
@@ -19,17 +19,14 @@ func TestInfoBinaryCommits(t *testing.T) {
|
| 19 | 19 |
info, err := client.Info(context.Background()) |
| 20 | 20 |
assert.NilError(t, err) |
| 21 | 21 |
|
| 22 |
- assert.Check(t, info.ContainerdCommit != nil) |
|
| 23 | 22 |
assert.Check(t, "N/A" != info.ContainerdCommit.ID) |
| 24 | 23 |
assert.Check(t, is.Equal(testEnv.DaemonInfo.ContainerdCommit.Expected, info.ContainerdCommit.Expected)) |
| 25 | 24 |
assert.Check(t, is.Equal(info.ContainerdCommit.Expected, info.ContainerdCommit.ID)) |
| 26 | 25 |
|
| 27 |
- assert.Check(t, info.InitCommit != nil) |
|
| 28 | 26 |
assert.Check(t, "N/A" != info.InitCommit.ID) |
| 29 | 27 |
assert.Check(t, is.Equal(testEnv.DaemonInfo.InitCommit.Expected, info.InitCommit.Expected)) |
| 30 | 28 |
assert.Check(t, is.Equal(info.InitCommit.Expected, info.InitCommit.ID)) |
| 31 | 29 |
|
| 32 |
- assert.Check(t, info.RuncCommit != nil) |
|
| 33 | 30 |
assert.Check(t, "N/A" != info.RuncCommit.ID) |
| 34 | 31 |
assert.Check(t, is.Equal(testEnv.DaemonInfo.RuncCommit.Expected, info.RuncCommit.Expected)) |
| 35 | 32 |
assert.Check(t, is.Equal(info.RuncCommit.Expected, info.RuncCommit.ID)) |
| ... | ... |
@@ -15,9 +15,9 @@ func TestVersion(t *testing.T) {
|
| 15 | 15 |
version, err := client.ServerVersion(context.Background()) |
| 16 | 16 |
assert.NilError(t, err) |
| 17 | 17 |
|
| 18 |
- assert.Check(t, version.APIVersion != nil) |
|
| 19 |
- assert.Check(t, version.Version != nil) |
|
| 20 |
- assert.Check(t, version.MinAPIVersion != nil) |
|
| 18 |
+ assert.Check(t, version.APIVersion != "") |
|
| 19 |
+ assert.Check(t, version.Version != "") |
|
| 20 |
+ assert.Check(t, version.MinAPIVersion != "") |
|
| 21 | 21 |
assert.Check(t, is.Equal(testEnv.DaemonInfo.ExperimentalBuild, version.Experimental)) |
| 22 | 22 |
assert.Check(t, is.Equal(testEnv.OSType, version.Os)) |
| 23 | 23 |
} |
| ... | ... |
@@ -4,14 +4,20 @@ import ( |
| 4 | 4 |
"io" |
| 5 | 5 |
|
| 6 | 6 |
"github.com/gotestyourself/gotestyourself/assert" |
| 7 |
- is "github.com/gotestyourself/gotestyourself/assert/cmp" |
|
| 8 | 7 |
) |
| 9 | 8 |
|
| 9 |
+type helperT interface {
|
|
| 10 |
+ Helper() |
|
| 11 |
+} |
|
| 12 |
+ |
|
| 10 | 13 |
// ErrorContains checks that the error is not nil, and contains the expected |
| 11 | 14 |
// substring. |
| 15 |
+// Deprecated: use assert.Assert(t, cmp.ErrorContains(err, expected)) |
|
| 12 | 16 |
func ErrorContains(t assert.TestingT, err error, expectedError string, msgAndArgs ...interface{}) {
|
| 13 |
- assert.Assert(t, is.ErrorContains(err, ""), msgAndArgs) |
|
| 14 |
- assert.Check(t, is.Contains(err.Error(), expectedError), msgAndArgs) |
|
| 17 |
+ if ht, ok := t.(helperT); ok {
|
|
| 18 |
+ ht.Helper() |
|
| 19 |
+ } |
|
| 20 |
+ assert.ErrorContains(t, err, expectedError, msgAndArgs...) |
|
| 15 | 21 |
} |
| 16 | 22 |
|
| 17 | 23 |
// DevZero acts like /dev/zero but in an OS-independent fashion. |
| ... | ... |
@@ -10,6 +10,7 @@ import ( |
| 10 | 10 |
"os" |
| 11 | 11 |
"os/exec" |
| 12 | 12 |
"path/filepath" |
| 13 |
+ "reflect" |
|
| 13 | 14 |
"runtime" |
| 14 | 15 |
"strings" |
| 15 | 16 |
"testing" |
| ... | ... |
@@ -1338,7 +1339,7 @@ func TestDisablePigz(t *testing.T) {
|
| 1338 | 1338 |
// For the context canceller |
| 1339 | 1339 |
contextReaderCloserWrapper := outsideReaderCloserWrapper.Reader.(*ioutils.ReadCloserWrapper) |
| 1340 | 1340 |
|
| 1341 |
- assert.IsType(t, &gzip.Reader{}, contextReaderCloserWrapper.Reader)
|
|
| 1341 |
+ assert.Equal(t, reflect.TypeOf(contextReaderCloserWrapper.Reader), reflect.TypeOf(&gzip.Reader{}))
|
|
| 1342 | 1342 |
} |
| 1343 | 1343 |
|
| 1344 | 1344 |
func TestPigz(t *testing.T) {
|
| ... | ... |
@@ -1351,9 +1352,9 @@ func TestPigz(t *testing.T) {
|
| 1351 | 1351 |
_, err := exec.LookPath("unpigz")
|
| 1352 | 1352 |
if err == nil {
|
| 1353 | 1353 |
t.Log("Tested whether Pigz is used, as it installed")
|
| 1354 |
- assert.IsType(t, &io.PipeReader{}, contextReaderCloserWrapper.Reader)
|
|
| 1354 |
+ assert.Equal(t, reflect.TypeOf(contextReaderCloserWrapper.Reader), reflect.TypeOf(&io.PipeReader{}))
|
|
| 1355 | 1355 |
} else {
|
| 1356 | 1356 |
t.Log("Tested whether Pigz is not used, as it not installed")
|
| 1357 |
- assert.IsType(t, &gzip.Reader{}, contextReaderCloserWrapper.Reader)
|
|
| 1357 |
+ assert.Equal(t, reflect.TypeOf(contextReaderCloserWrapper.Reader), reflect.TypeOf(&gzip.Reader{}))
|
|
| 1358 | 1358 |
} |
| 1359 | 1359 |
} |
| ... | ... |
@@ -15,7 +15,6 @@ import ( |
| 15 | 15 |
"github.com/docker/docker/pkg/plugins/transport" |
| 16 | 16 |
"github.com/docker/go-connections/tlsconfig" |
| 17 | 17 |
"github.com/gotestyourself/gotestyourself/assert" |
| 18 |
- is "github.com/gotestyourself/gotestyourself/assert/cmp" |
|
| 19 | 18 |
"github.com/pkg/errors" |
| 20 | 19 |
) |
| 21 | 20 |
|
| ... | ... |
@@ -55,7 +54,6 @@ func testActive(t *testing.T, p *Plugin) {
|
| 55 | 55 |
t.Fatalf("%s:%d: deadlock in waitActive", filepath.Base(f), l)
|
| 56 | 56 |
case <-done: |
| 57 | 57 |
} |
| 58 |
- |
|
| 59 | 58 |
} |
| 60 | 59 |
|
| 61 | 60 |
func TestGet(t *testing.T) {
|
| ... | ... |
@@ -79,12 +77,11 @@ func TestGet(t *testing.T) {
|
| 79 | 79 |
|
| 80 | 80 |
// check negative case where plugin fruit doesn't implement banana |
| 81 | 81 |
_, err = Get("fruit", "banana")
|
| 82 |
- assert.Check(t, is.DeepEqual(errors.Cause(err), ErrNotImplements)) |
|
| 82 |
+ assert.Equal(t, errors.Cause(err), ErrNotImplements) |
|
| 83 | 83 |
|
| 84 | 84 |
// check negative case where plugin vegetable doesn't exist |
| 85 | 85 |
_, err = Get("vegetable", "potato")
|
| 86 |
- assert.Check(t, is.DeepEqual(errors.Cause(err), ErrNotFound)) |
|
| 87 |
- |
|
| 86 |
+ assert.Equal(t, errors.Cause(err), ErrNotFound) |
|
| 88 | 87 |
} |
| 89 | 88 |
|
| 90 | 89 |
func TestPluginWithNoManifest(t *testing.T) {
|
| ... | ... |
@@ -17,7 +17,7 @@ func TestEscapeProxyRead(t *testing.T) {
|
| 17 | 17 |
nr, err := reader.Read(buf) |
| 18 | 18 |
assert.NilError(t, err) |
| 19 | 19 |
assert.Equal(t, nr, len(keys), fmt.Sprintf("nr %d should be equal to the number of %d", nr, len(keys)))
|
| 20 |
- assert.Assert(t, is.DeepEqual(keys, buf), "keys & the read buffer should be equal") |
|
| 20 |
+ assert.DeepEqual(t, keys, buf) |
|
| 21 | 21 |
|
| 22 | 22 |
keys, _ = ToBytes("")
|
| 23 | 23 |
reader = NewEscapeProxy(bytes.NewReader(keys), escapeKeys) |
| ... | ... |
@@ -35,7 +35,7 @@ func TestEscapeProxyRead(t *testing.T) {
|
| 35 | 35 |
nr, err = reader.Read(buf) |
| 36 | 36 |
assert.NilError(t, err) |
| 37 | 37 |
assert.Equal(t, nr, 1, fmt.Sprintf("nr %d should be equal to the number of 1", nr))
|
| 38 |
- assert.Assert(t, is.DeepEqual(keys, buf), "keys & the read buffer should be equal") |
|
| 38 |
+ assert.DeepEqual(t, keys, buf) |
|
| 39 | 39 |
|
| 40 | 40 |
escapeKeys, _ = ToBytes("ctrl-c")
|
| 41 | 41 |
keys, _ = ToBytes("ctrl-c")
|
| ... | ... |
@@ -44,7 +44,7 @@ func TestEscapeProxyRead(t *testing.T) {
|
| 44 | 44 |
nr, err = reader.Read(buf) |
| 45 | 45 |
assert.Error(t, err, "read escape sequence") |
| 46 | 46 |
assert.Equal(t, nr, 0, "nr should be equal to 0") |
| 47 |
- assert.Assert(t, is.DeepEqual(keys, buf), "keys & the read buffer should be equal") |
|
| 47 |
+ assert.DeepEqual(t, keys, buf) |
|
| 48 | 48 |
|
| 49 | 49 |
escapeKeys, _ = ToBytes("ctrl-c,ctrl-z")
|
| 50 | 50 |
keys, _ = ToBytes("ctrl-c,ctrl-z")
|
| ... | ... |
@@ -53,11 +53,11 @@ func TestEscapeProxyRead(t *testing.T) {
|
| 53 | 53 |
nr, err = reader.Read(buf) |
| 54 | 54 |
assert.NilError(t, err) |
| 55 | 55 |
assert.Equal(t, nr, 0, "nr should be equal to 0") |
| 56 |
- assert.Assert(t, is.DeepEqual(keys[0:1], buf), "keys & the read buffer should be equal") |
|
| 56 |
+ assert.DeepEqual(t, keys[0:1], buf) |
|
| 57 | 57 |
nr, err = reader.Read(buf) |
| 58 | 58 |
assert.Error(t, err, "read escape sequence") |
| 59 | 59 |
assert.Equal(t, nr, 0, "nr should be equal to 0") |
| 60 |
- assert.Assert(t, is.DeepEqual(keys[1:], buf), "keys & the read buffer should be equal") |
|
| 60 |
+ assert.DeepEqual(t, keys[1:], buf) |
|
| 61 | 61 |
|
| 62 | 62 |
escapeKeys, _ = ToBytes("ctrl-c,ctrl-z")
|
| 63 | 63 |
keys, _ = ToBytes("ctrl-c,DEL,+")
|
| ... | ... |
@@ -66,12 +66,12 @@ func TestEscapeProxyRead(t *testing.T) {
|
| 66 | 66 |
nr, err = reader.Read(buf) |
| 67 | 67 |
assert.NilError(t, err) |
| 68 | 68 |
assert.Equal(t, nr, 0, "nr should be equal to 0") |
| 69 |
- assert.Assert(t, is.DeepEqual(keys[0:1], buf), "keys & the read buffer should be equal") |
|
| 69 |
+ assert.DeepEqual(t, keys[0:1], buf) |
|
| 70 | 70 |
buf = make([]byte, len(keys)) |
| 71 | 71 |
nr, err = reader.Read(buf) |
| 72 | 72 |
assert.NilError(t, err) |
| 73 | 73 |
assert.Equal(t, nr, len(keys), fmt.Sprintf("nr should be equal to %d", len(keys)))
|
| 74 |
- assert.Assert(t, is.DeepEqual(keys, buf), "keys & the read buffer should be equal") |
|
| 74 |
+ assert.DeepEqual(t, keys, buf) |
|
| 75 | 75 |
|
| 76 | 76 |
escapeKeys, _ = ToBytes("ctrl-c,ctrl-z")
|
| 77 | 77 |
keys, _ = ToBytes("ctrl-c,DEL")
|
| ... | ... |
@@ -80,10 +80,10 @@ func TestEscapeProxyRead(t *testing.T) {
|
| 80 | 80 |
nr, err = reader.Read(buf) |
| 81 | 81 |
assert.NilError(t, err) |
| 82 | 82 |
assert.Equal(t, nr, 0, "nr should be equal to 0") |
| 83 |
- assert.Assert(t, is.DeepEqual(keys[0:1], buf), "keys & the read buffer should be equal") |
|
| 83 |
+ assert.DeepEqual(t, keys[0:1], buf) |
|
| 84 | 84 |
buf = make([]byte, len(keys)) |
| 85 | 85 |
nr, err = reader.Read(buf) |
| 86 | 86 |
assert.NilError(t, err) |
| 87 | 87 |
assert.Equal(t, nr, len(keys), fmt.Sprintf("nr should be equal to %d", len(keys)))
|
| 88 |
- assert.Assert(t, is.DeepEqual(keys, buf), "keys & the read buffer should be equal") |
|
| 88 |
+ assert.DeepEqual(t, keys, buf) |
|
| 89 | 89 |
} |
| ... | ... |
@@ -7,6 +7,7 @@ import ( |
| 7 | 7 |
"os" |
| 8 | 8 |
"testing" |
| 9 | 9 |
|
| 10 |
+ "github.com/google/go-cmp/cmp" |
|
| 10 | 11 |
"github.com/gotestyourself/gotestyourself/assert" |
| 11 | 12 |
) |
| 12 | 13 |
|
| ... | ... |
@@ -35,16 +36,17 @@ func TestGetWinsize(t *testing.T) {
|
| 35 | 35 |
winSize, err := GetWinsize(tty.Fd()) |
| 36 | 36 |
assert.NilError(t, err) |
| 37 | 37 |
assert.Assert(t, winSize != nil) |
| 38 |
- assert.Assert(t, winSize.Height != nil) |
|
| 39 |
- assert.Assert(t, winSize.Width != nil) |
|
| 38 |
+ |
|
| 40 | 39 |
newSize := Winsize{Width: 200, Height: 200, x: winSize.x, y: winSize.y}
|
| 41 | 40 |
err = SetWinsize(tty.Fd(), &newSize) |
| 42 | 41 |
assert.NilError(t, err) |
| 43 | 42 |
winSize, err = GetWinsize(tty.Fd()) |
| 44 | 43 |
assert.NilError(t, err) |
| 45 |
- assert.DeepEqual(t, *winSize, newSize) |
|
| 44 |
+ assert.DeepEqual(t, *winSize, newSize, cmpWinsize) |
|
| 46 | 45 |
} |
| 47 | 46 |
|
| 47 |
+var cmpWinsize = cmp.AllowUnexported(Winsize{})
|
|
| 48 |
+ |
|
| 48 | 49 |
func TestSetWinsize(t *testing.T) {
|
| 49 | 50 |
tty, err := newTtyForTest(t) |
| 50 | 51 |
defer tty.Close() |
| ... | ... |
@@ -57,7 +59,7 @@ func TestSetWinsize(t *testing.T) {
|
| 57 | 57 |
assert.NilError(t, err) |
| 58 | 58 |
winSize, err = GetWinsize(tty.Fd()) |
| 59 | 59 |
assert.NilError(t, err) |
| 60 |
- assert.DeepEqual(t, *winSize, newSize) |
|
| 60 |
+ assert.DeepEqual(t, *winSize, newSize, cmpWinsize) |
|
| 61 | 61 |
} |
| 62 | 62 |
|
| 63 | 63 |
func TestGetFdInfo(t *testing.T) {
|
| ... | ... |
@@ -12,6 +12,7 @@ import ( |
| 12 | 12 |
"github.com/docker/docker/volume" |
| 13 | 13 |
"github.com/docker/docker/volume/drivers" |
| 14 | 14 |
volumetestutils "github.com/docker/docker/volume/testutils" |
| 15 |
+ "github.com/google/go-cmp/cmp" |
|
| 15 | 16 |
"github.com/gotestyourself/gotestyourself/assert" |
| 16 | 17 |
is "github.com/gotestyourself/gotestyourself/assert/cmp" |
| 17 | 18 |
) |
| ... | ... |
@@ -359,7 +360,7 @@ func TestGet(t *testing.T) {
|
| 359 | 359 |
|
| 360 | 360 |
v2, err := s.Get("test")
|
| 361 | 361 |
assert.NilError(t, err) |
| 362 |
- assert.DeepEqual(t, v1, v2) |
|
| 362 |
+ assert.DeepEqual(t, v1, v2, cmpVolume) |
|
| 363 | 363 |
|
| 364 | 364 |
dv := v2.(volume.DetailedVolume) |
| 365 | 365 |
assert.Equal(t, "1", dv.Labels()["a"]) |
| ... | ... |
@@ -383,7 +384,7 @@ func TestGetWithRef(t *testing.T) {
|
| 383 | 383 |
|
| 384 | 384 |
v2, err := s.GetWithRef("test", driverName, "test-ref")
|
| 385 | 385 |
assert.NilError(t, err) |
| 386 |
- assert.DeepEqual(t, v1, v2) |
|
| 386 |
+ assert.DeepEqual(t, v1, v2, cmpVolume) |
|
| 387 | 387 |
|
| 388 | 388 |
err = s.Remove(v2) |
| 389 | 389 |
assert.Assert(t, is.ErrorContains(err, "")) |
| ... | ... |
@@ -394,6 +395,8 @@ func TestGetWithRef(t *testing.T) {
|
| 394 | 394 |
assert.NilError(t, err) |
| 395 | 395 |
} |
| 396 | 396 |
|
| 397 |
+var cmpVolume = cmp.AllowUnexported(volumetestutils.FakeVolume{}, volumeWrapper{})
|
|
| 398 |
+ |
|
| 397 | 399 |
func setupTest(t *testing.T, name string) (*VolumeStore, func(*testing.T)) {
|
| 398 | 400 |
t.Helper() |
| 399 | 401 |
s, cleanup := newTestStore(t) |