bump(github.com/stretchr/testify/mock):
This commit is contained in:
@ -94,23 +94,23 @@ func (m *Mock) Return(returnArguments ...interface{}) *Mock {
|
|||||||
// Once indicates that that the mock should only return the value once.
|
// Once indicates that that the mock should only return the value once.
|
||||||
//
|
//
|
||||||
// Mock.On("MyMethod", arg1, arg2).Return(returnArg1, returnArg2).Once()
|
// Mock.On("MyMethod", arg1, arg2).Return(returnArg1, returnArg2).Once()
|
||||||
func (m* Mock) Once() {
|
func (m *Mock) Once() {
|
||||||
m.ExpectedCalls[len(m.ExpectedCalls) - 1].Repeatability = 1
|
m.ExpectedCalls[len(m.ExpectedCalls)-1].Repeatability = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
// Twice indicates that that the mock should only return the value twice.
|
// Twice indicates that that the mock should only return the value twice.
|
||||||
//
|
//
|
||||||
// Mock.On("MyMethod", arg1, arg2).Return(returnArg1, returnArg2).Twice()
|
// Mock.On("MyMethod", arg1, arg2).Return(returnArg1, returnArg2).Twice()
|
||||||
func (m* Mock) Twice() {
|
func (m *Mock) Twice() {
|
||||||
m.ExpectedCalls[len(m.ExpectedCalls) - 1].Repeatability = 2
|
m.ExpectedCalls[len(m.ExpectedCalls)-1].Repeatability = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
// Times indicates that that the mock should only return the indicated number
|
// Times indicates that that the mock should only return the indicated number
|
||||||
// of times.
|
// of times.
|
||||||
//
|
//
|
||||||
// Mock.On("MyMethod", arg1, arg2).Return(returnArg1, returnArg2).Times(5)
|
// Mock.On("MyMethod", arg1, arg2).Return(returnArg1, returnArg2).Times(5)
|
||||||
func (m* Mock) Times(i int) {
|
func (m *Mock) Times(i int) {
|
||||||
m.ExpectedCalls[len(m.ExpectedCalls) - 1].Repeatability = i
|
m.ExpectedCalls[len(m.ExpectedCalls)-1].Repeatability = i
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -369,22 +369,22 @@ func (args Arguments) Diff(objects []interface{}) (string, int) {
|
|||||||
for i := 0; i < maxArgCount; i++ {
|
for i := 0; i < maxArgCount; i++ {
|
||||||
var actual, expected interface{}
|
var actual, expected interface{}
|
||||||
|
|
||||||
if len(args) <= i {
|
if len(objects) <= i {
|
||||||
actual = "(Missing)"
|
actual = "(Missing)"
|
||||||
} else {
|
} else {
|
||||||
actual = args[i]
|
actual = objects[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(objects) <= i {
|
if len(args) <= i {
|
||||||
expected = "(Missing)"
|
expected = "(Missing)"
|
||||||
} else {
|
} else {
|
||||||
expected = objects[i]
|
expected = args[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
if reflect.TypeOf(expected) == reflect.TypeOf((*AnythingOfTypeArgument)(nil)).Elem() {
|
if reflect.TypeOf(expected) == reflect.TypeOf((*AnythingOfTypeArgument)(nil)).Elem() {
|
||||||
|
|
||||||
// type checking
|
// type checking
|
||||||
if reflect.TypeOf(actual).Name() != string(expected.(AnythingOfTypeArgument)) {
|
if reflect.TypeOf(actual).Name() != string(expected.(AnythingOfTypeArgument)) && reflect.TypeOf(actual).String() != string(expected.(AnythingOfTypeArgument)) {
|
||||||
// not match
|
// not match
|
||||||
differences++
|
differences++
|
||||||
output = fmt.Sprintf("%s\t%d: \u274C type %s != type %s - %s\n", output, i, expected, reflect.TypeOf(actual).Name(), actual)
|
output = fmt.Sprintf("%s\t%d: \u274C type %s != type %s - %s\n", output, i, expected, reflect.TypeOf(actual).Name(), actual)
|
||||||
@ -396,11 +396,11 @@ func (args Arguments) Diff(objects []interface{}) (string, int) {
|
|||||||
|
|
||||||
if assert.ObjectsAreEqual(expected, Anything) || assert.ObjectsAreEqual(actual, Anything) || assert.ObjectsAreEqual(actual, expected) {
|
if assert.ObjectsAreEqual(expected, Anything) || assert.ObjectsAreEqual(actual, Anything) || assert.ObjectsAreEqual(actual, expected) {
|
||||||
// match
|
// match
|
||||||
output = fmt.Sprintf("%s\t%d: \u2705 %s == %s\n", output, i, expected, actual)
|
output = fmt.Sprintf("%s\t%d: \u2705 %s == %s\n", output, i, actual, expected)
|
||||||
} else {
|
} else {
|
||||||
// not match
|
// not match
|
||||||
differences++
|
differences++
|
||||||
output = fmt.Sprintf("%s\t%d: \u274C %s != %s\n", output, i, expected, actual)
|
output = fmt.Sprintf("%s\t%d: \u274C %s != %s\n", output, i, actual, expected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -542,9 +542,9 @@ func Test_Arguments_Diff_WithAnythingArgument_InActualToo(t *testing.T) {
|
|||||||
|
|
||||||
func Test_Arguments_Diff_WithAnythingOfTypeArgument(t *testing.T) {
|
func Test_Arguments_Diff_WithAnythingOfTypeArgument(t *testing.T) {
|
||||||
|
|
||||||
var args Arguments = []interface{}{"string", 123, true}
|
var args Arguments = []interface{}{"string", AnythingOfType("int"), true}
|
||||||
var count int
|
var count int
|
||||||
_, count = args.Diff([]interface{}{"string", AnythingOfType("int"), true})
|
_, count = args.Diff([]interface{}{"string", 123, true})
|
||||||
|
|
||||||
assert.Equal(t, 0, count)
|
assert.Equal(t, 0, count)
|
||||||
|
|
||||||
@ -552,10 +552,10 @@ func Test_Arguments_Diff_WithAnythingOfTypeArgument(t *testing.T) {
|
|||||||
|
|
||||||
func Test_Arguments_Diff_WithAnythingOfTypeArgument_Failing(t *testing.T) {
|
func Test_Arguments_Diff_WithAnythingOfTypeArgument_Failing(t *testing.T) {
|
||||||
|
|
||||||
var args Arguments = []interface{}{"string", 123, true}
|
var args Arguments = []interface{}{"string", AnythingOfType("string"), true}
|
||||||
var count int
|
var count int
|
||||||
var diff string
|
var diff string
|
||||||
diff, count = args.Diff([]interface{}{"string", AnythingOfType("string"), true})
|
diff, count = args.Diff([]interface{}{"string", 123, true})
|
||||||
|
|
||||||
assert.Equal(t, 1, count)
|
assert.Equal(t, 1, count)
|
||||||
assert.Contains(t, diff, `string != type int - %!s(int=123)`)
|
assert.Contains(t, diff, `string != type int - %!s(int=123)`)
|
||||||
|
Reference in New Issue
Block a user