mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
bump(github.com/stretchr/testify): 9cc77fa25329013ce07362c7742952ff887361f2
This commit is contained in:
parent
2557992b70
commit
d7d20d1c3d
@ -7,7 +7,7 @@ import (
|
|||||||
|
|
||||||
"github.com/coreos/etcd/server"
|
"github.com/coreos/etcd/server"
|
||||||
"github.com/coreos/etcd/tests"
|
"github.com/coreos/etcd/tests"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/coreos/etcd/third_party/github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Ensure that a leader can be set and read.
|
// Ensure that a leader can be set and read.
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
|
|
||||||
"github.com/coreos/etcd/server"
|
"github.com/coreos/etcd/server"
|
||||||
"github.com/coreos/etcd/tests"
|
"github.com/coreos/etcd/tests"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/coreos/etcd/third_party/github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Ensure that a lock can be acquired and released.
|
// Ensure that a lock can be acquired and released.
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/coreos/etcd/third_party/github.com/BurntSushi/toml"
|
"github.com/coreos/etcd/third_party/github.com/BurntSushi/toml"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/coreos/etcd/third_party/github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Ensures that a configuration can be deserialized from TOML.
|
// Ensures that a configuration can be deserialized from TOML.
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
"github.com/coreos/etcd/server"
|
"github.com/coreos/etcd/server"
|
||||||
"github.com/coreos/etcd/tests"
|
"github.com/coreos/etcd/tests"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/coreos/etcd/third_party/github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Ensures that a key is deleted.
|
// Ensures that a key is deleted.
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
"github.com/coreos/etcd/server"
|
"github.com/coreos/etcd/server"
|
||||||
"github.com/coreos/etcd/tests"
|
"github.com/coreos/etcd/tests"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/coreos/etcd/third_party/github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Ensures that a value can be retrieve for a given key.
|
// Ensures that a value can be retrieve for a given key.
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
|
|
||||||
"github.com/coreos/etcd/server"
|
"github.com/coreos/etcd/server"
|
||||||
"github.com/coreos/etcd/tests"
|
"github.com/coreos/etcd/tests"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/coreos/etcd/third_party/github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Ensures a unique value is added to the key's children.
|
// Ensures a unique value is added to the key's children.
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
"github.com/coreos/etcd/server"
|
"github.com/coreos/etcd/server"
|
||||||
"github.com/coreos/etcd/tests"
|
"github.com/coreos/etcd/tests"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/coreos/etcd/third_party/github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Ensures that a key is set to a given value.
|
// Ensures that a key is set to a given value.
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/coreos/etcd/third_party/github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Ensure that a successful Get is recorded in the stats.
|
// Ensure that a successful Get is recorded in the stats.
|
||||||
|
@ -21,7 +21,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
etcdErr "github.com/coreos/etcd/error"
|
etcdErr "github.com/coreos/etcd/error"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/coreos/etcd/third_party/github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Ensure that the store can retrieve an existing value.
|
// Ensure that the store can retrieve an existing value.
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/coreos/etcd/tests"
|
"github.com/coreos/etcd/tests"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/coreos/etcd/third_party/github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Ensure that we can start a v2 node from the log of a v1 node.
|
// Ensure that we can start a v2 node from the log of a v1 node.
|
||||||
|
@ -3,7 +3,7 @@ package raft
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/coreos/etcd/third_party/github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Ensure that we can listen and dispatch events.
|
// Ensure that we can listen and dispatch events.
|
||||||
|
471
third_party/github.com/stretchr/testify/assert/assertions.go
vendored
Normal file
471
third_party/github.com/stretchr/testify/assert/assertions.go
vendored
Normal file
@ -0,0 +1,471 @@
|
|||||||
|
package assert
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"reflect"
|
||||||
|
"runtime"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TestingT is an interface wrapper around *testing.T
|
||||||
|
type TestingT interface {
|
||||||
|
Errorf(format string, args ...interface{})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Comparison a custom function that returns true on success and false on failure
|
||||||
|
type Comparison func() (success bool)
|
||||||
|
|
||||||
|
/*
|
||||||
|
Helper functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
// ObjectsAreEqual determines if two objects are considered equal.
|
||||||
|
//
|
||||||
|
// This function does no assertion of any kind.
|
||||||
|
func ObjectsAreEqual(expected, actual interface{}) bool {
|
||||||
|
|
||||||
|
if reflect.DeepEqual(expected, actual) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
if reflect.ValueOf(expected) == reflect.ValueOf(actual) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Last ditch effort
|
||||||
|
if fmt.Sprintf("%#v", expected) == fmt.Sprintf("%#v", actual) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* CallerInfo is necessary because the assert functions use the testing object
|
||||||
|
internally, causing it to print the file:line of the assert method, rather than where
|
||||||
|
the problem actually occured in calling code.*/
|
||||||
|
|
||||||
|
// CallerInfo returns a string containing the file and line number of the assert call
|
||||||
|
// that failed.
|
||||||
|
func CallerInfo() string {
|
||||||
|
|
||||||
|
file := ""
|
||||||
|
line := 0
|
||||||
|
ok := false
|
||||||
|
|
||||||
|
for i := 0; ; i++ {
|
||||||
|
_, file, line, ok = runtime.Caller(i)
|
||||||
|
if !ok {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
parts := strings.Split(file, "/")
|
||||||
|
dir := parts[len(parts)-2]
|
||||||
|
file = parts[len(parts)-1]
|
||||||
|
if (dir != "assert" && dir != "mock") || file == "mock_test.go" {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Sprintf("%s:%d", file, line)
|
||||||
|
}
|
||||||
|
|
||||||
|
// getWhitespaceString returns a string that is long enough to overwrite the default
|
||||||
|
// output from the go testing framework.
|
||||||
|
func getWhitespaceString() string {
|
||||||
|
|
||||||
|
_, file, line, ok := runtime.Caller(1)
|
||||||
|
if !ok {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
parts := strings.Split(file, "/")
|
||||||
|
file = parts[len(parts)-1]
|
||||||
|
|
||||||
|
return strings.Repeat(" ", len(fmt.Sprintf("%s:%d: ", file, line)))
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func messageFromMsgAndArgs(msgAndArgs ...interface{}) string {
|
||||||
|
if len(msgAndArgs) == 0 || msgAndArgs == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
if len(msgAndArgs) == 1 {
|
||||||
|
return msgAndArgs[0].(string)
|
||||||
|
}
|
||||||
|
if len(msgAndArgs) > 1 {
|
||||||
|
return fmt.Sprintf(msgAndArgs[0].(string), msgAndArgs[1:]...)
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fail reports a failure through
|
||||||
|
func Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) bool {
|
||||||
|
|
||||||
|
message := messageFromMsgAndArgs(msgAndArgs...)
|
||||||
|
|
||||||
|
if len(message) > 0 {
|
||||||
|
t.Errorf("\r%s\r\tLocation:\t%s\n\r\tError:\t\t%s\n\r\tMessages:\t%s\n\r", getWhitespaceString(), CallerInfo(), failureMessage, message)
|
||||||
|
} else {
|
||||||
|
t.Errorf("\r%s\r\tLocation:\t%s\n\r\tError:\t\t%s\n\r", getWhitespaceString(), CallerInfo(), failureMessage)
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Implements asserts that an object is implemented by the specified interface.
|
||||||
|
//
|
||||||
|
// assert.Implements(t, (*MyInterface)(nil), new(MyObject), "MyObject")
|
||||||
|
func Implements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
|
||||||
|
interfaceType := reflect.TypeOf(interfaceObject).Elem()
|
||||||
|
|
||||||
|
if !reflect.TypeOf(object).Implements(interfaceType) {
|
||||||
|
return Fail(t, fmt.Sprintf("Object must implement %v", interfaceType), msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsType asserts that the specified objects are of the same type.
|
||||||
|
func IsType(t TestingT, expectedType interface{}, object interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
|
||||||
|
if !ObjectsAreEqual(reflect.TypeOf(object), reflect.TypeOf(expectedType)) {
|
||||||
|
return Fail(t, fmt.Sprintf("Object expected to be of type %v, but was %v", reflect.TypeOf(expectedType), reflect.TypeOf(object)), msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Equal asserts that two objects are equal.
|
||||||
|
//
|
||||||
|
// assert.Equal(t, 123, 123, "123 and 123 should be equal")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Equal(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
|
||||||
|
if !ObjectsAreEqual(expected, actual) {
|
||||||
|
return Fail(t, fmt.Sprintf("Not equal: %#v != %#v", expected, actual), msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exactly asserts that two objects are equal is value and type.
|
||||||
|
//
|
||||||
|
// assert.Exactly(t, int32(123), int64(123), "123 and 123 should NOT be equal")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Exactly(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
|
||||||
|
aType := reflect.TypeOf(expected)
|
||||||
|
bType := reflect.TypeOf(actual)
|
||||||
|
|
||||||
|
if aType != bType {
|
||||||
|
return Fail(t, "Types expected to match exactly", "%v != %v", aType, bType)
|
||||||
|
}
|
||||||
|
|
||||||
|
return Equal(t, expected, actual, msgAndArgs...)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotNil asserts that the specified object is not nil.
|
||||||
|
//
|
||||||
|
// assert.NotNil(t, err, "err should be something")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
|
||||||
|
var success bool = true
|
||||||
|
|
||||||
|
if object == nil {
|
||||||
|
success = false
|
||||||
|
} else {
|
||||||
|
value := reflect.ValueOf(object)
|
||||||
|
kind := value.Kind()
|
||||||
|
if kind >= reflect.Chan && kind <= reflect.Slice && value.IsNil() {
|
||||||
|
success = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !success {
|
||||||
|
Fail(t, "Expected not to be nil.", msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
return success
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nil asserts that the specified object is nil.
|
||||||
|
//
|
||||||
|
// assert.Nil(t, err, "err should be nothing")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
|
||||||
|
if object == nil {
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
value := reflect.ValueOf(object)
|
||||||
|
kind := value.Kind()
|
||||||
|
if kind >= reflect.Chan && kind <= reflect.Slice && value.IsNil() {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Fail(t, fmt.Sprintf("Expected nil, but got: %#v", object), msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// isEmpty gets whether the specified object is considered empty or not.
|
||||||
|
func isEmpty(object interface{}) bool {
|
||||||
|
|
||||||
|
if object == nil {
|
||||||
|
return true
|
||||||
|
} else if object == "" {
|
||||||
|
return true
|
||||||
|
} else if object == 0 {
|
||||||
|
return true
|
||||||
|
} else if object == false {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
objValue := reflect.ValueOf(object)
|
||||||
|
switch objValue.Kind() {
|
||||||
|
case reflect.Map:
|
||||||
|
fallthrough
|
||||||
|
case reflect.Slice:
|
||||||
|
{
|
||||||
|
return (objValue.Len() == 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or a
|
||||||
|
// slice with len == 0.
|
||||||
|
//
|
||||||
|
// assert.Empty(t, obj)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
|
||||||
|
pass := isEmpty(object)
|
||||||
|
if !pass {
|
||||||
|
Fail(t, fmt.Sprintf("Should be empty, but was %v", object), msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
return pass
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Empty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or a
|
||||||
|
// slice with len == 0.
|
||||||
|
//
|
||||||
|
// if assert.NotEmpty(t, obj) {
|
||||||
|
// assert.Equal(t, "two", obj[1])
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
|
||||||
|
pass := !isEmpty(object)
|
||||||
|
if !pass {
|
||||||
|
Fail(t, fmt.Sprintf("Should NOT be empty, but was %v", object), msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
return pass
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// True asserts that the specified value is true.
|
||||||
|
//
|
||||||
|
// assert.True(t, myBool, "myBool should be true")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func True(t TestingT, value bool, msgAndArgs ...interface{}) bool {
|
||||||
|
|
||||||
|
if value != true {
|
||||||
|
return Fail(t, "Should be true", msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// False asserts that the specified value is true.
|
||||||
|
//
|
||||||
|
// assert.False(t, myBool, "myBool should be false")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func False(t TestingT, value bool, msgAndArgs ...interface{}) bool {
|
||||||
|
|
||||||
|
if value != false {
|
||||||
|
return Fail(t, "Should be false", msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotEqual asserts that the specified values are NOT equal.
|
||||||
|
//
|
||||||
|
// assert.NotEqual(t, obj1, obj2, "two objects shouldn't be equal")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NotEqual(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
|
||||||
|
if ObjectsAreEqual(expected, actual) {
|
||||||
|
return Fail(t, "Should not be equal", msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Contains asserts that the specified string contains the specified substring.
|
||||||
|
//
|
||||||
|
// assert.Contains(t, "Hello World", "World", "But 'Hello World' does contain 'World'")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Contains(t TestingT, s, contains string, msgAndArgs ...interface{}) bool {
|
||||||
|
|
||||||
|
if !strings.Contains(s, contains) {
|
||||||
|
return Fail(t, fmt.Sprintf("\"%s\" does not contain \"%s\"", s, contains), msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotContains asserts that the specified string does NOT contain the specified substring.
|
||||||
|
//
|
||||||
|
// assert.NotContains(t, "Hello World", "Earth", "But 'Hello World' does NOT contain 'Earth'")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NotContains(t TestingT, s, contains string, msgAndArgs ...interface{}) bool {
|
||||||
|
|
||||||
|
if strings.Contains(s, contains) {
|
||||||
|
return Fail(t, fmt.Sprintf("\"%s\" should not contain \"%s\"", s, contains), msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Uses a Comparison to assert a complex condition.
|
||||||
|
func Condition(t TestingT, comp Comparison, msgAndArgs ...interface{}) bool {
|
||||||
|
result := comp()
|
||||||
|
if !result {
|
||||||
|
Fail(t, "Condition failed!", msgAndArgs...)
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
// PanicTestFunc defines a func that should be passed to the assert.Panics and assert.NotPanics
|
||||||
|
// methods, and represents a simple func that takes no arguments, and returns nothing.
|
||||||
|
type PanicTestFunc func()
|
||||||
|
|
||||||
|
// didPanic returns true if the function passed to it panics. Otherwise, it returns false.
|
||||||
|
func didPanic(f PanicTestFunc) (bool, interface{}) {
|
||||||
|
|
||||||
|
var didPanic bool = false
|
||||||
|
var message interface{}
|
||||||
|
func() {
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
if message = recover(); message != nil {
|
||||||
|
didPanic = true
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
// call the target function
|
||||||
|
f()
|
||||||
|
|
||||||
|
}()
|
||||||
|
|
||||||
|
return didPanic, message
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Panics asserts that the code inside the specified PanicTestFunc panics.
|
||||||
|
//
|
||||||
|
// assert.Panics(t, func(){
|
||||||
|
// GoCrazy()
|
||||||
|
// }, "Calling GoCrazy() should panic")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Panics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool {
|
||||||
|
|
||||||
|
if funcDidPanic, panicValue := didPanic(f); !funcDidPanic {
|
||||||
|
return Fail(t, fmt.Sprintf("func %#v should panic\n\r\tPanic value:\t%v", f, panicValue), msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
|
||||||
|
//
|
||||||
|
// assert.NotPanics(t, func(){
|
||||||
|
// RemainCalm()
|
||||||
|
// }, "Calling RemainCalm() should NOT panic")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NotPanics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool {
|
||||||
|
|
||||||
|
if funcDidPanic, panicValue := didPanic(f); funcDidPanic {
|
||||||
|
return Fail(t, fmt.Sprintf("func %#v should not panic\n\r\tPanic value:\t%v", f, panicValue), msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithinDuration asserts that the two times are within duration delta of each other.
|
||||||
|
//
|
||||||
|
// assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second, "The difference should not be more than 10s")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func WithinDuration(t TestingT, expected, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) bool {
|
||||||
|
|
||||||
|
dt := expected.Sub(actual)
|
||||||
|
if dt < -delta || dt > delta {
|
||||||
|
return Fail(t, fmt.Sprintf("Max difference between %v and %v allowed is %v, but difference was %v", expected, actual, dt, delta), msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Errors
|
||||||
|
*/
|
||||||
|
|
||||||
|
// NoError asserts that a function returned no error (i.e. `nil`).
|
||||||
|
//
|
||||||
|
// actualObj, err := SomeFunction()
|
||||||
|
// if assert.NoError(t, err) {
|
||||||
|
// assert.Equal(t, actualObj, expectedObj)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NoError(t TestingT, theError error, msgAndArgs ...interface{}) bool {
|
||||||
|
|
||||||
|
message := messageFromMsgAndArgs(msgAndArgs...)
|
||||||
|
return Nil(t, theError, "No error is expected but got %v %s", theError, message)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Error asserts that a function returned an error (i.e. not `nil`).
|
||||||
|
//
|
||||||
|
// actualObj, err := SomeFunction()
|
||||||
|
// if assert.Error(t, err, "An error was expected") {
|
||||||
|
// assert.Equal(t, err, expectedError)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Error(t TestingT, theError error, msgAndArgs ...interface{}) bool {
|
||||||
|
|
||||||
|
message := messageFromMsgAndArgs(msgAndArgs...)
|
||||||
|
return NotNil(t, theError, "An error is expected but got nil. %s", message)
|
||||||
|
|
||||||
|
}
|
385
third_party/github.com/stretchr/testify/assert/assertions_test.go
vendored
Normal file
385
third_party/github.com/stretchr/testify/assert/assertions_test.go
vendored
Normal file
@ -0,0 +1,385 @@
|
|||||||
|
package assert
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AssertionTesterInterface defines an interface to be used for testing assertion methods
|
||||||
|
type AssertionTesterInterface interface {
|
||||||
|
TestMethod()
|
||||||
|
}
|
||||||
|
|
||||||
|
// AssertionTesterConformingObject is an object that conforms to the AssertionTesterInterface interface
|
||||||
|
type AssertionTesterConformingObject struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *AssertionTesterConformingObject) TestMethod() {
|
||||||
|
}
|
||||||
|
|
||||||
|
// AssertionTesterNonConformingObject is an object that does not conform to the AssertionTesterInterface interface
|
||||||
|
type AssertionTesterNonConformingObject struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestObjectsAreEqual(t *testing.T) {
|
||||||
|
|
||||||
|
if !ObjectsAreEqual("Hello World", "Hello World") {
|
||||||
|
t.Error("objectsAreEqual should return true")
|
||||||
|
}
|
||||||
|
if !ObjectsAreEqual(123, 123) {
|
||||||
|
t.Error("objectsAreEqual should return true")
|
||||||
|
}
|
||||||
|
if !ObjectsAreEqual(123.5, 123.5) {
|
||||||
|
t.Error("objectsAreEqual should return true")
|
||||||
|
}
|
||||||
|
if !ObjectsAreEqual([]byte("Hello World"), []byte("Hello World")) {
|
||||||
|
t.Error("objectsAreEqual should return true")
|
||||||
|
}
|
||||||
|
if !ObjectsAreEqual(nil, nil) {
|
||||||
|
t.Error("objectsAreEqual should return true")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestImplements(t *testing.T) {
|
||||||
|
|
||||||
|
mockT := new(testing.T)
|
||||||
|
|
||||||
|
if !Implements(mockT, (*AssertionTesterInterface)(nil), new(AssertionTesterConformingObject)) {
|
||||||
|
t.Error("Implements method should return true: AssertionTesterConformingObject implements AssertionTesterInterface")
|
||||||
|
}
|
||||||
|
if Implements(mockT, (*AssertionTesterInterface)(nil), new(AssertionTesterNonConformingObject)) {
|
||||||
|
t.Error("Implements method should return false: AssertionTesterNonConformingObject does not implements AssertionTesterInterface")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestIsType(t *testing.T) {
|
||||||
|
|
||||||
|
mockT := new(testing.T)
|
||||||
|
|
||||||
|
if !IsType(mockT, new(AssertionTesterConformingObject), new(AssertionTesterConformingObject)) {
|
||||||
|
t.Error("IsType should return true: AssertionTesterConformingObject is the same type as AssertionTesterConformingObject")
|
||||||
|
}
|
||||||
|
if IsType(mockT, new(AssertionTesterConformingObject), new(AssertionTesterNonConformingObject)) {
|
||||||
|
t.Error("IsType should return false: AssertionTesterConformingObject is not the same type as AssertionTesterNonConformingObject")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestEqual(t *testing.T) {
|
||||||
|
|
||||||
|
mockT := new(testing.T)
|
||||||
|
|
||||||
|
if !Equal(mockT, "Hello World", "Hello World") {
|
||||||
|
t.Error("Equal should return true")
|
||||||
|
}
|
||||||
|
if !Equal(mockT, 123, 123) {
|
||||||
|
t.Error("Equal should return true")
|
||||||
|
}
|
||||||
|
if !Equal(mockT, 123.5, 123.5) {
|
||||||
|
t.Error("Equal should return true")
|
||||||
|
}
|
||||||
|
if !Equal(mockT, []byte("Hello World"), []byte("Hello World")) {
|
||||||
|
t.Error("Equal should return true")
|
||||||
|
}
|
||||||
|
if !Equal(mockT, nil, nil) {
|
||||||
|
t.Error("Equal should return true")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNotNil(t *testing.T) {
|
||||||
|
|
||||||
|
mockT := new(testing.T)
|
||||||
|
|
||||||
|
if !NotNil(mockT, new(AssertionTesterConformingObject)) {
|
||||||
|
t.Error("NotNil should return true: object is not nil")
|
||||||
|
}
|
||||||
|
if NotNil(mockT, nil) {
|
||||||
|
t.Error("NotNil should return false: object is nil")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNil(t *testing.T) {
|
||||||
|
|
||||||
|
mockT := new(testing.T)
|
||||||
|
|
||||||
|
if !Nil(mockT, nil) {
|
||||||
|
t.Error("Nil should return true: object is nil")
|
||||||
|
}
|
||||||
|
if Nil(mockT, new(AssertionTesterConformingObject)) {
|
||||||
|
t.Error("Nil should return false: object is not nil")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTrue(t *testing.T) {
|
||||||
|
|
||||||
|
mockT := new(testing.T)
|
||||||
|
|
||||||
|
if !True(mockT, true) {
|
||||||
|
t.Error("True should return true")
|
||||||
|
}
|
||||||
|
if True(mockT, false) {
|
||||||
|
t.Error("True should return false")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFalse(t *testing.T) {
|
||||||
|
|
||||||
|
mockT := new(testing.T)
|
||||||
|
|
||||||
|
if !False(mockT, false) {
|
||||||
|
t.Error("False should return true")
|
||||||
|
}
|
||||||
|
if False(mockT, true) {
|
||||||
|
t.Error("False should return false")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestExactly(t *testing.T) {
|
||||||
|
|
||||||
|
mockT := new(testing.T)
|
||||||
|
|
||||||
|
a := float32(1)
|
||||||
|
b := float64(1)
|
||||||
|
c := float32(1)
|
||||||
|
d := float32(2)
|
||||||
|
|
||||||
|
if Exactly(mockT, a, b) {
|
||||||
|
t.Error("Exactly should return false")
|
||||||
|
}
|
||||||
|
if Exactly(mockT, a, d) {
|
||||||
|
t.Error("Exactly should return false")
|
||||||
|
}
|
||||||
|
if !Exactly(mockT, a, c) {
|
||||||
|
t.Error("Exactly should return true")
|
||||||
|
}
|
||||||
|
|
||||||
|
if Exactly(mockT, nil, a) {
|
||||||
|
t.Error("Exactly should return false")
|
||||||
|
}
|
||||||
|
if Exactly(mockT, a, nil) {
|
||||||
|
t.Error("Exactly should return false")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNotEqual(t *testing.T) {
|
||||||
|
|
||||||
|
mockT := new(testing.T)
|
||||||
|
|
||||||
|
if !NotEqual(mockT, "Hello World", "Hello World!") {
|
||||||
|
t.Error("NotEqual should return true")
|
||||||
|
}
|
||||||
|
if !NotEqual(mockT, 123, 1234) {
|
||||||
|
t.Error("NotEqual should return true")
|
||||||
|
}
|
||||||
|
if !NotEqual(mockT, 123.5, 123.55) {
|
||||||
|
t.Error("NotEqual should return true")
|
||||||
|
}
|
||||||
|
if !NotEqual(mockT, []byte("Hello World"), []byte("Hello World!")) {
|
||||||
|
t.Error("NotEqual should return true")
|
||||||
|
}
|
||||||
|
if !NotEqual(mockT, nil, new(AssertionTesterConformingObject)) {
|
||||||
|
t.Error("NotEqual should return true")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestContains(t *testing.T) {
|
||||||
|
|
||||||
|
mockT := new(testing.T)
|
||||||
|
|
||||||
|
if !Contains(mockT, "Hello World", "Hello") {
|
||||||
|
t.Error("Contains should return true: \"Hello World\" contains \"Hello\"")
|
||||||
|
}
|
||||||
|
if Contains(mockT, "Hello World", "Salut") {
|
||||||
|
t.Error("Contains should return false: \"Hello World\" does not contain \"Salut\"")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNotContains(t *testing.T) {
|
||||||
|
|
||||||
|
mockT := new(testing.T)
|
||||||
|
|
||||||
|
if !NotContains(mockT, "Hello World", "Hello!") {
|
||||||
|
t.Error("NotContains should return true: \"Hello World\" does not contain \"Hello!\"")
|
||||||
|
}
|
||||||
|
if NotContains(mockT, "Hello World", "Hello") {
|
||||||
|
t.Error("NotContains should return false: \"Hello World\" contains \"Hello\"")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDidPanic(t *testing.T) {
|
||||||
|
|
||||||
|
if funcDidPanic, _ := didPanic(func() {
|
||||||
|
panic("Panic!")
|
||||||
|
}); !funcDidPanic {
|
||||||
|
t.Error("didPanic should return true")
|
||||||
|
}
|
||||||
|
|
||||||
|
if funcDidPanic, _ := didPanic(func() {
|
||||||
|
}); funcDidPanic {
|
||||||
|
t.Error("didPanic should return false")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPanics(t *testing.T) {
|
||||||
|
|
||||||
|
mockT := new(testing.T)
|
||||||
|
|
||||||
|
if !Panics(mockT, func() {
|
||||||
|
panic("Panic!")
|
||||||
|
}) {
|
||||||
|
t.Error("Panics should return true")
|
||||||
|
}
|
||||||
|
|
||||||
|
if Panics(mockT, func() {
|
||||||
|
}) {
|
||||||
|
t.Error("Panics should return false")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNotPanics(t *testing.T) {
|
||||||
|
|
||||||
|
mockT := new(testing.T)
|
||||||
|
|
||||||
|
if !NotPanics(mockT, func() {
|
||||||
|
}) {
|
||||||
|
t.Error("NotPanics should return true")
|
||||||
|
}
|
||||||
|
|
||||||
|
if NotPanics(mockT, func() {
|
||||||
|
panic("Panic!")
|
||||||
|
}) {
|
||||||
|
t.Error("NotPanics should return false")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestEqual_Funcs(t *testing.T) {
|
||||||
|
|
||||||
|
type f func() int
|
||||||
|
var f1 f = func() int { return 1 }
|
||||||
|
var f2 f = func() int { return 2 }
|
||||||
|
|
||||||
|
var f1_copy f = f1
|
||||||
|
|
||||||
|
Equal(t, f1_copy, f1, "Funcs are the same and should be considered equal")
|
||||||
|
NotEqual(t, f1, f2, "f1 and f2 are different")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNoError(t *testing.T) {
|
||||||
|
|
||||||
|
mockT := new(testing.T)
|
||||||
|
|
||||||
|
// start with a nil error
|
||||||
|
var err error = nil
|
||||||
|
|
||||||
|
True(t, NoError(mockT, err), "NoError should return True for nil arg")
|
||||||
|
|
||||||
|
// now set an error
|
||||||
|
err = errors.New("Some error")
|
||||||
|
|
||||||
|
False(t, NoError(mockT, err), "NoError with error should return False")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestError(t *testing.T) {
|
||||||
|
|
||||||
|
mockT := new(testing.T)
|
||||||
|
|
||||||
|
// start with a nil error
|
||||||
|
var err error = nil
|
||||||
|
|
||||||
|
False(t, Error(mockT, err), "Error should return False for nil arg")
|
||||||
|
|
||||||
|
// now set an error
|
||||||
|
err = errors.New("Some error")
|
||||||
|
|
||||||
|
True(t, Error(mockT, err), "Error with error should return True")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_isEmpty(t *testing.T) {
|
||||||
|
|
||||||
|
True(t, isEmpty(""))
|
||||||
|
True(t, isEmpty(nil))
|
||||||
|
True(t, isEmpty([]string{}))
|
||||||
|
True(t, isEmpty(0))
|
||||||
|
True(t, isEmpty(false))
|
||||||
|
True(t, isEmpty(map[string]string{}))
|
||||||
|
|
||||||
|
False(t, isEmpty("something"))
|
||||||
|
False(t, isEmpty(errors.New("something")))
|
||||||
|
False(t, isEmpty([]string{"something"}))
|
||||||
|
False(t, isEmpty(1))
|
||||||
|
False(t, isEmpty(true))
|
||||||
|
False(t, isEmpty(map[string]string{"Hello": "World"}))
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestEmpty(t *testing.T) {
|
||||||
|
|
||||||
|
mockT := new(testing.T)
|
||||||
|
|
||||||
|
True(t, Empty(mockT, ""), "Empty string is empty")
|
||||||
|
True(t, Empty(mockT, nil), "Nil is empty")
|
||||||
|
True(t, Empty(mockT, []string{}), "Empty string array is empty")
|
||||||
|
True(t, Empty(mockT, 0), "Zero int value is empty")
|
||||||
|
True(t, Empty(mockT, false), "False value is empty")
|
||||||
|
|
||||||
|
False(t, Empty(mockT, "something"), "Non Empty string is not empty")
|
||||||
|
False(t, Empty(mockT, errors.New("something")), "Non nil object is not empty")
|
||||||
|
False(t, Empty(mockT, []string{"something"}), "Non empty string array is not empty")
|
||||||
|
False(t, Empty(mockT, 1), "Non-zero int value is not empty")
|
||||||
|
False(t, Empty(mockT, true), "True value is not empty")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNotEmpty(t *testing.T) {
|
||||||
|
|
||||||
|
mockT := new(testing.T)
|
||||||
|
|
||||||
|
False(t, NotEmpty(mockT, ""), "Empty string is empty")
|
||||||
|
False(t, NotEmpty(mockT, nil), "Nil is empty")
|
||||||
|
False(t, NotEmpty(mockT, []string{}), "Empty string array is empty")
|
||||||
|
False(t, NotEmpty(mockT, 0), "Zero int value is empty")
|
||||||
|
False(t, NotEmpty(mockT, false), "False value is empty")
|
||||||
|
|
||||||
|
True(t, NotEmpty(mockT, "something"), "Non Empty string is not empty")
|
||||||
|
True(t, NotEmpty(mockT, errors.New("something")), "Non nil object is not empty")
|
||||||
|
True(t, NotEmpty(mockT, []string{"something"}), "Non empty string array is not empty")
|
||||||
|
True(t, NotEmpty(mockT, 1), "Non-zero int value is not empty")
|
||||||
|
True(t, NotEmpty(mockT, true), "True value is not empty")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWithinDuration(t *testing.T) {
|
||||||
|
|
||||||
|
mockT := new(testing.T)
|
||||||
|
a := time.Now()
|
||||||
|
b := a.Add(10 * time.Second)
|
||||||
|
|
||||||
|
True(t, WithinDuration(mockT, a, b, 10*time.Second), "A 10s difference is within a 10s time difference")
|
||||||
|
True(t, WithinDuration(mockT, b, a, 10*time.Second), "A 10s difference is within a 10s time difference")
|
||||||
|
|
||||||
|
False(t, WithinDuration(mockT, a, b, 9*time.Second), "A 10s difference is not within a 9s time difference")
|
||||||
|
False(t, WithinDuration(mockT, b, a, 9*time.Second), "A 10s difference is not within a 9s time difference")
|
||||||
|
|
||||||
|
False(t, WithinDuration(mockT, a, b, -9*time.Second), "A 10s difference is not within a 9s time difference")
|
||||||
|
False(t, WithinDuration(mockT, b, a, -9*time.Second), "A 10s difference is not within a 9s time difference")
|
||||||
|
|
||||||
|
False(t, WithinDuration(mockT, a, b, -11*time.Second), "A 10s difference is not within a 9s time difference")
|
||||||
|
False(t, WithinDuration(mockT, b, a, -11*time.Second), "A 10s difference is not within a 9s time difference")
|
||||||
|
}
|
74
third_party/github.com/stretchr/testify/assert/doc.go
vendored
Normal file
74
third_party/github.com/stretchr/testify/assert/doc.go
vendored
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
// A set of comprehensive testing tools for use with the normal Go testing system.
|
||||||
|
//
|
||||||
|
// Example Usage
|
||||||
|
//
|
||||||
|
// The following is a complete example using assert in a standard test function:
|
||||||
|
// import (
|
||||||
|
// "testing"
|
||||||
|
// "github.com/stretchr/testify/assert"
|
||||||
|
// )
|
||||||
|
//
|
||||||
|
// func TestSomething(t *testing.T) {
|
||||||
|
//
|
||||||
|
// var a string = "Hello"
|
||||||
|
// var b string = "Hello"
|
||||||
|
//
|
||||||
|
// assert.Equal(t, a, b, "The two words should be the same.")
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Assertions
|
||||||
|
//
|
||||||
|
// Assertions allow you to easily write test code, and are global funcs in the `assert` package.
|
||||||
|
// All assertion functions take, as the first argument, the `*testing.T` object provided by the
|
||||||
|
// testing framework. This allows the assertion funcs to write the failings and other details to
|
||||||
|
// the correct place.
|
||||||
|
//
|
||||||
|
// Every assertion function also takes an optional string message as the final argument,
|
||||||
|
// allowing custom error messages to be appended to the message the assertion method outputs.
|
||||||
|
//
|
||||||
|
// Here is an overview of the assert functions:
|
||||||
|
//
|
||||||
|
// assert.Equal(t, expected, actual [, message [, format-args])
|
||||||
|
//
|
||||||
|
// assert.NotEqual(t, notExpected, actual [, message [, format-args]])
|
||||||
|
//
|
||||||
|
// assert.True(t, actualBool [, message [, format-args]])
|
||||||
|
//
|
||||||
|
// assert.False(t, actualBool [, message [, format-args]])
|
||||||
|
//
|
||||||
|
// assert.Nil(t, actualObject [, message [, format-args]])
|
||||||
|
//
|
||||||
|
// assert.NotNil(t, actualObject [, message [, format-args]])
|
||||||
|
//
|
||||||
|
// assert.Empty(t, actualObject [, message [, format-args]])
|
||||||
|
//
|
||||||
|
// assert.NotEmpty(t, actualObject [, message [, format-args]])
|
||||||
|
//
|
||||||
|
// assert.Error(t, errorObject [, message [, format-args]])
|
||||||
|
//
|
||||||
|
// assert.NoError(t, errorObject [, message [, format-args]])
|
||||||
|
//
|
||||||
|
// assert.Implements(t, (*MyInterface)(nil), new(MyObject) [,message [, format-args]])
|
||||||
|
//
|
||||||
|
// assert.IsType(t, expectedObject, actualObject [, message [, format-args]])
|
||||||
|
//
|
||||||
|
// assert.Contains(t, string, substring [, message [, format-args]])
|
||||||
|
//
|
||||||
|
// assert.NotContains(t, string, substring [, message [, format-args]])
|
||||||
|
//
|
||||||
|
// assert.Panics(t, func(){
|
||||||
|
//
|
||||||
|
// // call code that should panic
|
||||||
|
//
|
||||||
|
// } [, message [, format-args]])
|
||||||
|
//
|
||||||
|
// assert.NotPanics(t, func(){
|
||||||
|
//
|
||||||
|
// // call code that should not panic
|
||||||
|
//
|
||||||
|
// } [, message [, format-args]])
|
||||||
|
//
|
||||||
|
// assert.WithinDuration(t, timeA, timeB, deltaTime, [, message [, format-args]])
|
||||||
|
|
||||||
|
package assert
|
10
third_party/github.com/stretchr/testify/assert/errors.go
vendored
Normal file
10
third_party/github.com/stretchr/testify/assert/errors.go
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package assert
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AnError is an erorr instance useful for testing. If the code does not care
|
||||||
|
// about error specifics, and only needs to return the error for example, this
|
||||||
|
// error should be used to make the test code more readable.
|
||||||
|
var AnError error = errors.New("assert.AnError general error for testing.")
|
Loading…
x
Reference in New Issue
Block a user