vendor: update all dependencies
This commit is contained in:
parent
3f0789e2db
commit
08021c4636
2474 changed files with 435818 additions and 282709 deletions
216
vendor/github.com/stretchr/testify/assert/assertions_test.go
generated
vendored
216
vendor/github.com/stretchr/testify/assert/assertions_test.go
generated
vendored
|
@ -2,6 +2,7 @@ package assert
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
|
@ -250,6 +251,21 @@ func (t *bufferT) Errorf(format string, args ...interface{}) {
|
|||
t.buf.WriteString(decorate(fmt.Sprintf(format, args...)))
|
||||
}
|
||||
|
||||
func TestStringEqual(t *testing.T) {
|
||||
for i, currCase := range []struct {
|
||||
equalWant string
|
||||
equalGot string
|
||||
msgAndArgs []interface{}
|
||||
want string
|
||||
}{
|
||||
{equalWant: "hi, \nmy name is", equalGot: "what,\nmy name is", want: "\tassertions.go:\\d+: \n\t+Error Trace:\t\n\t+Error:\\s+Not equal:\\s+\n\\s+expected: \"hi, \\\\nmy name is\"\n\\s+actual\\s+: \"what,\\\\nmy name is\"\n\\s+Diff:\n\\s+-+ Expected\n\\s+\\++ Actual\n\\s+@@ -1,2 \\+1,2 @@\n\\s+-hi, \n\\s+\\+what,\n\\s+my name is"},
|
||||
} {
|
||||
mockT := &bufferT{}
|
||||
Equal(mockT, currCase.equalWant, currCase.equalGot, currCase.msgAndArgs...)
|
||||
Regexp(t, regexp.MustCompile(currCase.want), mockT.buf.String(), "Case %d", i)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEqualFormatting(t *testing.T) {
|
||||
for i, currCase := range []struct {
|
||||
equalWant string
|
||||
|
@ -257,8 +273,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 \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"},
|
||||
{equalWant: "want", equalGot: "got", want: "\tassertions.go:\\d+: \n\t+Error Trace:\t\n\t+Error:\\s+Not equal:\\s+\n\\s+expected: \"want\"\n\\s+actual\\s+: \"got\"\n\\s+Diff:\n\\s+-+ Expected\n\\s+\\++ Actual\n\\s+@@ -1 \\+1 @@\n\\s+-want\n\\s+\\+got\n"},
|
||||
{equalWant: "want", equalGot: "got", msgAndArgs: []interface{}{"hello, %v!", "world"}, want: "\tassertions.go:[0-9]+: \n\t+Error Trace:\t\n\t+Error:\\s+Not equal:\\s+\n\\s+expected: \"want\"\n\\s+actual\\s+: \"got\"\n\\s+Diff:\n\\s+-+ Expected\n\\s+\\++ Actual\n\\s+@@ -1 \\+1 @@\n\\s+-want\n\\s+\\+got\n\\s+Messages:\\s+hello, world!\n"},
|
||||
} {
|
||||
mockT := &bufferT{}
|
||||
Equal(mockT, currCase.equalWant, currCase.equalGot, currCase.msgAndArgs...)
|
||||
|
@ -1579,3 +1595,199 @@ func TestEqualArgsValidation(t *testing.T) {
|
|||
err := validateEqualArgs(time.Now, time.Now)
|
||||
EqualError(t, err, "cannot take func type as argument")
|
||||
}
|
||||
|
||||
func ExampleComparisonAssertionFunc() {
|
||||
t := &testing.T{} // provided by test
|
||||
|
||||
adder := func(x, y int) int {
|
||||
return x + y
|
||||
}
|
||||
|
||||
type args struct {
|
||||
x int
|
||||
y int
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
expect int
|
||||
assertion ComparisonAssertionFunc
|
||||
}{
|
||||
{"2+2=4", args{2, 2}, 4, Equal},
|
||||
{"2+2!=5", args{2, 2}, 5, NotEqual},
|
||||
{"2+3==5", args{2, 3}, 5, Exactly},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
tt.assertion(t, tt.expect, adder(tt.args.x, tt.args.y))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestComparisonAssertionFunc(t *testing.T) {
|
||||
type iface interface {
|
||||
Name() string
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
expect interface{}
|
||||
got interface{}
|
||||
assertion ComparisonAssertionFunc
|
||||
}{
|
||||
{"implements", (*iface)(nil), t, Implements},
|
||||
{"isType", (*testing.T)(nil), t, IsType},
|
||||
{"equal", t, t, Equal},
|
||||
{"equalValues", t, t, EqualValues},
|
||||
{"exactly", t, t, Exactly},
|
||||
{"notEqual", t, nil, NotEqual},
|
||||
{"notContains", []int{1, 2, 3}, 4, NotContains},
|
||||
{"subset", []int{1, 2, 3, 4}, []int{2, 3}, Subset},
|
||||
{"notSubset", []int{1, 2, 3, 4}, []int{0, 3}, NotSubset},
|
||||
{"elementsMatch", []byte("abc"), []byte("bac"), ElementsMatch},
|
||||
{"regexp", "^t.*y$", "testify", Regexp},
|
||||
{"notRegexp", "^t.*y$", "Testify", NotRegexp},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
tt.assertion(t, tt.expect, tt.got)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func ExampleValueAssertionFunc() {
|
||||
t := &testing.T{} // provided by test
|
||||
|
||||
dumbParse := func(input string) interface{} {
|
||||
var x interface{}
|
||||
json.Unmarshal([]byte(input), &x)
|
||||
return x
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
arg string
|
||||
assertion ValueAssertionFunc
|
||||
}{
|
||||
{"true is not nil", "true", NotNil},
|
||||
{"empty string is nil", "", Nil},
|
||||
{"zero is not nil", "0", NotNil},
|
||||
{"zero is zero", "0", Zero},
|
||||
{"false is zero", "false", Zero},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
tt.assertion(t, dumbParse(tt.arg))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestValueAssertionFunc(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
value interface{}
|
||||
assertion ValueAssertionFunc
|
||||
}{
|
||||
{"notNil", true, NotNil},
|
||||
{"nil", nil, Nil},
|
||||
{"empty", []int{}, Empty},
|
||||
{"notEmpty", []int{1}, NotEmpty},
|
||||
{"zero", false, Zero},
|
||||
{"notZero", 42, NotZero},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
tt.assertion(t, tt.value)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func ExampleBoolAssertionFunc() {
|
||||
t := &testing.T{} // provided by test
|
||||
|
||||
isOkay := func(x int) bool {
|
||||
return x >= 42
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
arg int
|
||||
assertion BoolAssertionFunc
|
||||
}{
|
||||
{"-1 is bad", -1, False},
|
||||
{"42 is good", 42, True},
|
||||
{"41 is bad", 41, False},
|
||||
{"45 is cool", 45, True},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
tt.assertion(t, isOkay(tt.arg))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestBoolAssertionFunc(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
value bool
|
||||
assertion BoolAssertionFunc
|
||||
}{
|
||||
{"true", true, True},
|
||||
{"false", false, False},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
tt.assertion(t, tt.value)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func ExampleErrorAssertionFunc() {
|
||||
t := &testing.T{} // provided by test
|
||||
|
||||
dumbParseNum := func(input string, v interface{}) error {
|
||||
return json.Unmarshal([]byte(input), v)
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
arg string
|
||||
assertion ErrorAssertionFunc
|
||||
}{
|
||||
{"1.2 is number", "1.2", NoError},
|
||||
{"1.2.3 not number", "1.2.3", Error},
|
||||
{"true is not number", "true", Error},
|
||||
{"3 is number", "3", NoError},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
var x float64
|
||||
tt.assertion(t, dumbParseNum(tt.arg, &x))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestErrorAssertionFunc(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
err error
|
||||
assertion ErrorAssertionFunc
|
||||
}{
|
||||
{"noError", nil, NoError},
|
||||
{"error", errors.New("whoops"), Error},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
tt.assertion(t, tt.err)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue