vendor: update all dependencies

This commit is contained in:
Nick Craig-Wood 2017-07-23 08:51:42 +01:00
parent 0b6fba34a3
commit eb87cf6f12
2008 changed files with 352633 additions and 1004750 deletions

View file

@ -254,8 +254,8 @@ func TestEqualFormatting(t *testing.T) {
msgAndArgs []interface{}
want string
}{
{equalWant: "want", equalGot: "got", want: "\tassertions.go:[0-9]+: \r \r\tError Trace:\t\n\t\t\r\tError: \tNot equal: \n\t\t\r\t \texpected: \"want\"\n\t\t\r\t \treceived: \"got\"\n"},
{equalWant: "want", equalGot: "got", msgAndArgs: []interface{}{"hello, %v!", "world"}, want: "\tassertions.go:[0-9]+: \r \r\tError Trace:\t\n\t\t\r\tError: \tNot equal: \n\t\t\r\t \texpected: \"want\"\n\t\t\r\t \treceived: \"got\"\n\t\t\r\tMessages: \thello, world!\n"},
{equalWant: "want", equalGot: "got", want: "\tassertions.go:[0-9]+: \r \r\tError Trace:\t\n\t\t\r\tError: \tNot equal: \n\t\t\r\t \texpected: \"want\"\n\t\t\r\t \tactual: \"got\"\n"},
{equalWant: "want", equalGot: "got", msgAndArgs: []interface{}{"hello, %v!", "world"}, want: "\tassertions.go:[0-9]+: \r \r\tError Trace:\t\n\t\t\r\tError: \tNot equal: \n\t\t\r\t \texpected: \"want\"\n\t\t\r\t \tactual: \"got\"\n\t\t\r\tMessages: \thello, world!\n"},
} {
mockT := &bufferT{}
Equal(mockT, currCase.equalWant, currCase.equalGot, currCase.msgAndArgs...)
@ -396,8 +396,8 @@ func TestNotEqual(t *testing.T) {
}
funcA := func() int { return 23 }
funcB := func() int { return 42 }
if !NotEqual(mockT, funcA, funcB) {
t.Error("NotEqual should return true")
if NotEqual(mockT, funcA, funcB) {
t.Error("NotEqual should return false")
}
if NotEqual(mockT, "Hello World", "Hello World") {
@ -493,6 +493,66 @@ func TestNotContains(t *testing.T) {
}
}
func TestSubset(t *testing.T) {
mockT := new(testing.T)
if !Subset(mockT, []int{1, 2, 3}, nil) {
t.Error("Subset should return true: given subset is nil")
}
if !Subset(mockT, []int{1, 2, 3}, []int{}) {
t.Error("Subset should return true: any set contains the nil set")
}
if !Subset(mockT, []int{1, 2, 3}, []int{1, 2}) {
t.Error("Subset should return true: [1, 2, 3] contains [1, 2]")
}
if !Subset(mockT, []int{1, 2, 3}, []int{1, 2, 3}) {
t.Error("Subset should return true: [1, 2, 3] contains [1, 2, 3]")
}
if !Subset(mockT, []string{"hello", "world"}, []string{"hello"}) {
t.Error("Subset should return true: [\"hello\", \"world\"] contains [\"hello\"]")
}
if Subset(mockT, []string{"hello", "world"}, []string{"hello", "testify"}) {
t.Error("Subset should return false: [\"hello\", \"world\"] does not contain [\"hello\", \"testify\"]")
}
if Subset(mockT, []int{1, 2, 3}, []int{4, 5}) {
t.Error("Subset should return false: [1, 2, 3] does not contain [4, 5]")
}
if Subset(mockT, []int{1, 2, 3}, []int{1, 5}) {
t.Error("Subset should return false: [1, 2, 3] does not contain [1, 5]")
}
}
func TestNotSubset(t *testing.T) {
mockT := new(testing.T)
if NotSubset(mockT, []int{1, 2, 3}, nil) {
t.Error("NotSubset should return false: given subset is nil")
}
if NotSubset(mockT, []int{1, 2, 3}, []int{}) {
t.Error("NotSubset should return false: any set contains the nil set")
}
if NotSubset(mockT, []int{1, 2, 3}, []int{1, 2}) {
t.Error("NotSubset should return false: [1, 2, 3] contains [1, 2]")
}
if NotSubset(mockT, []int{1, 2, 3}, []int{1, 2, 3}) {
t.Error("NotSubset should return false: [1, 2, 3] contains [1, 2, 3]")
}
if NotSubset(mockT, []string{"hello", "world"}, []string{"hello"}) {
t.Error("NotSubset should return false: [\"hello\", \"world\"] contains [\"hello\"]")
}
if !NotSubset(mockT, []string{"hello", "world"}, []string{"hello", "testify"}) {
t.Error("NotSubset should return true: [\"hello\", \"world\"] does not contain [\"hello\", \"testify\"]")
}
if !NotSubset(mockT, []int{1, 2, 3}, []int{4, 5}) {
t.Error("NotSubset should return true: [1, 2, 3] does not contain [4, 5]")
}
if !NotSubset(mockT, []int{1, 2, 3}, []int{1, 5}) {
t.Error("NotSubset should return true: [1, 2, 3] does not contain [1, 5]")
}
}
func Test_includeElement(t *testing.T) {
list1 := []string{"Foo", "Bar"}
@ -589,6 +649,28 @@ func TestPanics(t *testing.T) {
}
func TestPanicsWithValue(t *testing.T) {
mockT := new(testing.T)
if !PanicsWithValue(mockT, "Panic!", func() {
panic("Panic!")
}) {
t.Error("PanicsWithValue should return true")
}
if PanicsWithValue(mockT, "Panic!", func() {
}) {
t.Error("PanicsWithValue should return false")
}
if PanicsWithValue(mockT, "at the disco", func() {
panic("Panic!")
}) {
t.Error("PanicsWithValue should return false")
}
}
func TestNotPanics(t *testing.T) {
mockT := new(testing.T)
@ -630,7 +712,7 @@ func TestNoError(t *testing.T) {
}()
if err == nil { // err is not nil here!
t.Errorf("Error should be nil due to empty interface", err)
t.Errorf("Error should be nil due to empty interface: %s", err)
}
False(t, NoError(mockT, err), "NoError should fail with empty error interface")
@ -654,6 +736,9 @@ func TestError(t *testing.T) {
True(t, Error(mockT, err), "Error with error should return True")
// go vet check
True(t, Errorf(mockT, err, "example with %s", "formatted message"), "Errorf with error should rturn True")
// returning an empty error interface
err = func() error {
var err *customError
@ -664,7 +749,7 @@ func TestError(t *testing.T) {
}()
if err == nil { // err is not nil here!
t.Errorf("Error should be nil due to empty interface", err)
t.Errorf("Error should be nil due to empty interface: %s", err)
}
True(t, Error(mockT, err), "Error should pass with empty error interface")
@ -960,6 +1045,7 @@ func TestInEpsilon(t *testing.T) {
{uint64(100), uint8(101), 0.01},
{0.1, -0.1, 2},
{0.1, 0, 2},
{time.Second, time.Second + time.Millisecond, 0.002},
}
for _, tc := range cases {
@ -978,6 +1064,7 @@ func TestInEpsilon(t *testing.T) {
{2.1, "bla-bla", 0},
{0.1, -0.1, 1.99},
{0, 0.1, 2}, // expected must be different to zero
{time.Second, time.Second + 10*time.Millisecond, 0.002},
}
for _, tc := range cases {
@ -1283,3 +1370,37 @@ func TestFailNowWithFullTestingT(t *testing.T) {
FailNow(mockT, "failed")
}, "should call mockT.FailNow() rather than panicking")
}
func TestBytesEqual(t *testing.T) {
var cases = []struct {
a, b []byte
}{
{make([]byte, 2), make([]byte, 2)},
{make([]byte, 2), make([]byte, 2, 3)},
{nil, make([]byte, 0)},
}
for i, c := range cases {
Equal(t, reflect.DeepEqual(c.a, c.b), ObjectsAreEqual(c.a, c.b), "case %d failed", i+1)
}
}
func BenchmarkBytesEqual(b *testing.B) {
const size = 1024 * 8
s := make([]byte, size)
for i := range s {
s[i] = byte(i % 255)
}
s2 := make([]byte, size)
copy(s2, s)
mockT := &mockFailNowTestingT{}
b.ResetTimer()
for i := 0; i < b.N; i++ {
Equal(mockT, s, s2)
}
}
func TestEqualArgsValidation(t *testing.T) {
err := validateEqualArgs(time.Now, time.Now)
EqualError(t, err, "cannot take func type as argument")
}