vendor: update all dependencies
This commit is contained in:
parent
3f0789e2db
commit
08021c4636
2474 changed files with 435818 additions and 282709 deletions
197
vendor/github.com/stretchr/testify/require/requirements_test.go
generated
vendored
197
vendor/github.com/stretchr/testify/require/requirements_test.go
generated
vendored
|
@ -1,6 +1,7 @@
|
|||
package require
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"testing"
|
||||
"time"
|
||||
|
@ -367,3 +368,199 @@ func TestJSONEq_ArraysOfDifferentOrder(t *testing.T) {
|
|||
t.Error("Check should fail")
|
||||
}
|
||||
}
|
||||
|
||||
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