Skip to content

Commit da0cfd5

Browse files
committed
vendor: gotest.tools v3.0.2
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent a16ccc4 commit da0cfd5

28 files changed

+140
-92
lines changed

datastore/datastore_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77

88
"github.com/docker/libnetwork/options"
99
_ "github.com/docker/libnetwork/testutils"
10-
"gotest.tools/assert"
10+
"gotest.tools/v3/assert"
1111
)
1212

1313
var dummyKey = "dummy"

drivers/overlay/ovmanager/ovmanager_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
"github.com/docker/libnetwork/netlabel"
1212
_ "github.com/docker/libnetwork/testutils"
1313
"github.com/docker/libnetwork/types"
14-
"gotest.tools/assert"
15-
is "gotest.tools/assert/cmp"
14+
"gotest.tools/v3/assert"
15+
is "gotest.tools/v3/assert/cmp"
1616
)
1717

1818
func newDriver(t *testing.T) *driver {

drvregistry/drvregistry_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
builtinIpam "github.com/docker/libnetwork/ipams/builtin"
1212
nullIpam "github.com/docker/libnetwork/ipams/null"
1313
remoteIpam "github.com/docker/libnetwork/ipams/remote"
14-
"gotest.tools/assert"
15-
is "gotest.tools/assert/cmp"
14+
"gotest.tools/v3/assert"
15+
is "gotest.tools/v3/assert/cmp"
1616

1717
// this takes care of the incontainer flag
1818
_ "github.com/docker/libnetwork/testutils"

firewall_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/docker/libnetwork/iptables"
99
"github.com/docker/libnetwork/netlabel"
1010
"github.com/docker/libnetwork/options"
11-
"gotest.tools/assert"
11+
"gotest.tools/v3/assert"
1212
)
1313

1414
const (

ipam/allocator_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import (
1919
"github.com/docker/libnetwork/ipamapi"
2020
_ "github.com/docker/libnetwork/testutils"
2121
"github.com/docker/libnetwork/types"
22-
"gotest.tools/assert"
23-
is "gotest.tools/assert/cmp"
22+
"gotest.tools/v3/assert"
23+
is "gotest.tools/v3/assert/cmp"
2424
)
2525

2626
const (

ipam/parallel_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313

1414
"github.com/docker/libnetwork/ipamapi"
1515
"golang.org/x/sync/semaphore"
16-
"gotest.tools/assert"
17-
is "gotest.tools/assert/cmp"
16+
"gotest.tools/v3/assert"
17+
is "gotest.tools/v3/assert/cmp"
1818
)
1919

2020
const (

ipamutils/utils_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"testing"
66

77
_ "github.com/docker/libnetwork/testutils"
8-
"gotest.tools/assert"
9-
is "gotest.tools/assert/cmp"
8+
"gotest.tools/v3/assert"
9+
is "gotest.tools/v3/assert/cmp"
1010
)
1111

1212
func initBroadPredefinedNetworks() []*net.IPNet {

networkdb/networkdb_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import (
1515
"github.com/docker/go-events"
1616
"github.com/hashicorp/memberlist"
1717
"github.com/sirupsen/logrus"
18-
"gotest.tools/assert"
19-
is "gotest.tools/assert/cmp"
20-
"gotest.tools/poll"
18+
"gotest.tools/v3/assert"
19+
is "gotest.tools/v3/assert/cmp"
20+
"gotest.tools/v3/poll"
2121

2222
// this takes care of the incontainer flag
2323
_ "github.com/docker/libnetwork/testutils"

osl/kernel/knobs_linux_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"testing"
55

66
"github.com/sirupsen/logrus"
7-
"gotest.tools/assert"
8-
is "gotest.tools/assert/cmp"
7+
"gotest.tools/v3/assert"
8+
is "gotest.tools/v3/assert/cmp"
99

1010
_ "github.com/docker/libnetwork/testutils"
1111
)

service_common_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"testing"
66

77
"github.com/docker/libnetwork/resolvconf"
8-
"gotest.tools/assert"
9-
is "gotest.tools/assert/cmp"
8+
"gotest.tools/v3/assert"
9+
is "gotest.tools/v3/assert/cmp"
1010
)
1111

1212
func TestCleanupServiceDiscovery(t *testing.T) {

types/types_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"testing"
66

77
_ "github.com/docker/libnetwork/testutils"
8-
"gotest.tools/assert"
9-
is "gotest.tools/assert/cmp"
8+
"gotest.tools/v3/assert"
9+
is "gotest.tools/v3/assert/cmp"
1010
)
1111

1212
func TestTransportPortConv(t *testing.T) {

vendor.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ github.com/pkg/errors 614d223910a179a466c1767a9854
5050
github.com/ishidawataru/sctp 6e2cb1366111dcf547c13531e3a263a067715847
5151
go.opencensus.io 9c377598961b706d1542bd2d84d538b5094d596e # v0.22.0
5252

53-
gotest.tools 1083505acf35a0bd8a696b26837e1fb3187a7a83 # v2.3.0
53+
gotest.tools/v3 bb0d8a963040ea5048dcef1a14d8f8b58a33d4b3 # v3.0.2
5454
github.com/google/go-cmp 3af367b6b30c263d47e8895973edcca9a49cf029 # v0.2.0
5555

5656
github.com/moby/ipvs 4566ccea0e08d68e9614c3e7a64a23b850c4bb35 # v1.0.1

vendor/gotest.tools/go.mod

-8
This file was deleted.
File renamed without changes.

vendor/gotest.tools/README.md vendor/gotest.tools/v3/README.md

+23-8
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,41 @@
22

33
A collection of packages to augment `testing` and support common patterns.
44

5-
[![GoDoc](https://godoc.org/gotest.tools?status.svg)](https://godoc.org/gotest.tools)
5+
[![GoDoc](https://godoc.org/gotest.tools?status.svg)](http://gotest.tools)
66
[![CircleCI](https://circleci.com/gh/gotestyourself/gotest.tools/tree/master.svg?style=shield)](https://circleci.com/gh/gotestyourself/gotest.tools/tree/master)
77
[![Go Reportcard](https://goreportcard.com/badge/gotest.tools)](https://goreportcard.com/report/gotest.tools)
88

9+
## Usage
10+
11+
With Go modules enabled (go1.11+)
12+
13+
```
14+
$ go get gotest.tools/v3
15+
```
16+
17+
```
18+
import "gotest.tools/v3/assert"
19+
```
20+
21+
To use `gotest.tools` with an older version of Go that does not understand Go
22+
module paths pin to version `v2.3.0`.
23+
924

1025
## Packages
1126

12-
* [assert](http://godoc.org/gotest.tools/assert) -
27+
* [assert](http://gotest.tools/assert) -
1328
compare values and fail the test when a comparison fails
14-
* [env](http://godoc.org/gotest.tools/env) -
29+
* [env](http://gotest.tools/env) -
1530
test code which uses environment variables
16-
* [fs](http://godoc.org/gotest.tools/fs) -
31+
* [fs](http://gotest.tools/fs) -
1732
create temporary files and compare a filesystem tree to an expected value
18-
* [golden](http://godoc.org/gotest.tools/golden) -
33+
* [golden](http://gotest.tools/golden) -
1934
compare large multi-line strings against values frozen in golden files
20-
* [icmd](http://godoc.org/gotest.tools/icmd) -
35+
* [icmd](http://gotest.tools/icmd) -
2136
execute binaries and test the output
22-
* [poll](http://godoc.org/gotest.tools/poll) -
37+
* [poll](http://gotest.tools/poll) -
2338
test asynchronous code by polling until a desired state is reached
24-
* [skip](http://godoc.org/gotest.tools/skip) -
39+
* [skip](http://gotest.tools/skip) -
2540
skip a test and print the source code of the condition used to skip the test
2641

2742
## Related

vendor/gotest.tools/assert/assert.go vendor/gotest.tools/v3/assert/assert.go

+46-28
Original file line numberDiff line numberDiff line change
@@ -49,30 +49,31 @@ The example below shows assert used with some common types.
4949
5050
Comparisons
5151
52-
Package https://godoc.org/gotest.tools/assert/cmp provides
52+
Package http://gotest.tools/assert/cmp provides
5353
many common comparisons. Additional comparisons can be written to compare
5454
values in other ways. See the example Assert (CustomComparison).
5555
5656
Automated migration from testify
5757
58-
gty-migrate-from-testify is a binary which can update source code which uses
59-
testify assertions to use the assertions provided by this package.
58+
gty-migrate-from-testify is a command which translates Go source code from
59+
testify assertions to the assertions provided by this package.
6060
61-
See http://bit.do/cmd-gty-migrate-from-testify.
61+
See http://gotest.tools/assert/cmd/gty-migrate-from-testify.
6262
6363
6464
*/
65-
package assert // import "gotest.tools/assert"
65+
package assert // import "gotest.tools/v3/assert"
6666

6767
import (
6868
"fmt"
6969
"go/ast"
7070
"go/token"
71+
"reflect"
7172

7273
gocmp "github.com/google/go-cmp/cmp"
73-
"gotest.tools/assert/cmp"
74-
"gotest.tools/internal/format"
75-
"gotest.tools/internal/source"
74+
"gotest.tools/v3/assert/cmp"
75+
"gotest.tools/v3/internal/format"
76+
"gotest.tools/v3/internal/source"
7677
)
7778

7879
// BoolOrComparison can be a bool, or cmp.Comparison. See Assert() for usage.
@@ -118,8 +119,8 @@ func assert(
118119
return true
119120

120121
case error:
121-
msg := "error is not nil: "
122-
t.Log(format.WithCustomMessage(failureMessage+msg+check.Error(), msgAndArgs...))
122+
msg := failureMsgFromError(check)
123+
t.Log(format.WithCustomMessage(failureMessage+msg, msgAndArgs...))
123124

124125
case cmp.Comparison:
125126
success = runComparison(t, argSelector, check, msgAndArgs...)
@@ -174,6 +175,15 @@ func logFailureFromBool(t TestingT, msgAndArgs ...interface{}) {
174175
t.Log(format.WithCustomMessage(failureMessage+msg, msgAndArgs...))
175176
}
176177

178+
func failureMsgFromError(err error) string {
179+
// Handle errors with non-nil types
180+
v := reflect.ValueOf(err)
181+
if v.Kind() == reflect.Ptr && v.IsNil() {
182+
return fmt.Sprintf("error is not nil: error has type %T", err)
183+
}
184+
return "error is not nil: " + err.Error()
185+
}
186+
177187
func boolFailureMessage(expr ast.Expr) (string, error) {
178188
if binaryExpr, ok := expr.(*ast.BinaryExpr); ok && binaryExpr.Op == token.NEQ {
179189
x, err := source.FormatNode(binaryExpr.X)
@@ -202,17 +212,20 @@ func boolFailureMessage(expr ast.Expr) (string, error) {
202212
return "expression is false: " + formatted, nil
203213
}
204214

205-
// Assert performs a comparison. If the comparison fails the test is marked as
215+
// Assert performs a comparison. If the comparison fails, the test is marked as
206216
// failed, a failure message is logged, and execution is stopped immediately.
207217
//
208-
// The comparison argument may be one of three types: bool, cmp.Comparison or
209-
// error.
210-
// When called with a bool the failure message will contain the literal source
211-
// code of the expression.
212-
// When called with a cmp.Comparison the comparison is responsible for producing
213-
// a helpful failure message.
214-
// When called with an error a nil value is considered success. A non-nil error
215-
// is a failure, and Error() is used as the failure message.
218+
// The comparison argument may be one of three types:
219+
// bool
220+
// True is success. False is a failure.
221+
// The failure message will contain the literal source code of the expression.
222+
// cmp.Comparison
223+
// Uses cmp.Result.Success() to check for success of failure.
224+
// The comparison is responsible for producing a helpful failure message.
225+
// http://gotest.tools/assert/cmp provides many common comparisons.
226+
// error
227+
// A nil value is considered success.
228+
// A non-nil error is a failure, err.Error() is used as the failure message.
216229
func Assert(t TestingT, comparison BoolOrComparison, msgAndArgs ...interface{}) {
217230
if ht, ok := t.(helperT); ok {
218231
ht.Helper()
@@ -260,10 +273,10 @@ func Equal(t TestingT, x, y interface{}, msgAndArgs ...interface{}) {
260273
assert(t, t.FailNow, argsAfterT, cmp.Equal(x, y), msgAndArgs...)
261274
}
262275

263-
// DeepEqual uses google/go-cmp (http://bit.do/go-cmp) to assert two values are
264-
// equal and fails the test if they are not equal.
276+
// DeepEqual uses google/go-cmp (https://godoc.org/github.com/google/go-cmp/cmp)
277+
// to assert two values are equal and fails the test if they are not equal.
265278
//
266-
// Package https://godoc.org/gotest.tools/assert/opt provides some additional
279+
// Package http://gotest.tools/assert/opt provides some additional
267280
// commonly used Options.
268281
//
269282
// This is equivalent to Assert(t, cmp.DeepEqual(x, y)).
@@ -295,14 +308,19 @@ func ErrorContains(t TestingT, err error, substring string, msgAndArgs ...interf
295308
}
296309

297310
// ErrorType fails the test if err is nil, or err is not the expected type.
311+
// Equivalent to Assert(t, cmp.ErrorType(err, expected)).
298312
//
299313
// Expected can be one of:
300-
// a func(error) bool which returns true if the error is the expected type,
301-
// an instance of (or a pointer to) a struct of the expected type,
302-
// a pointer to an interface the error is expected to implement,
303-
// a reflect.Type of the expected struct or interface.
304-
//
305-
// Equivalent to Assert(t, cmp.ErrorType(err, expected)).
314+
// func(error) bool
315+
// Function should return true if the error is the expected type.
316+
// type struct{}, type &struct{}
317+
// A struct or a pointer to a struct.
318+
// Fails if the error is not of the same type as expected.
319+
// type &interface{}
320+
// A pointer to an interface type.
321+
// Fails if err does not implement the interface.
322+
// reflect.Type
323+
// Fails if err does not implement the reflect.Type
306324
func ErrorType(t TestingT, err error, expected interface{}, msgAndArgs ...interface{}) {
307325
if ht, ok := t.(helperT); ok {
308326
ht.Helper()

0 commit comments

Comments
 (0)