mirror of
https://github.com/rclone/rclone.git
synced 2025-12-20 18:23:31 +00:00
vendor: update all dependencies
This commit is contained in:
47
vendor/github.com/stretchr/testify/mock/mock_test.go
generated
vendored
47
vendor/github.com/stretchr/testify/mock/mock_test.go
generated
vendored
@@ -2,10 +2,11 @@ package mock
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
/*
|
||||
@@ -55,6 +56,11 @@ func (i *TestExampleImplementation) TheExampleMethodVariadicInterface(a ...inter
|
||||
return args.Error(0)
|
||||
}
|
||||
|
||||
func (i *TestExampleImplementation) TheExampleMethodMixedVariadic(a int, b ...int) error {
|
||||
args := i.Called(a, b)
|
||||
return args.Error(0)
|
||||
}
|
||||
|
||||
type ExampleFuncType func(string) error
|
||||
|
||||
func (i *TestExampleImplementation) TheExampleMethodFuncType(fn ExampleFuncType) error {
|
||||
@@ -226,6 +232,29 @@ func Test_Mock_On_WithVariadicFunc(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
func Test_Mock_On_WithMixedVariadicFunc(t *testing.T) {
|
||||
|
||||
// make a test impl object
|
||||
var mockedService = new(TestExampleImplementation)
|
||||
|
||||
c := mockedService.
|
||||
On("TheExampleMethodMixedVariadic", 1, []int{2, 3, 4}).
|
||||
Return(nil)
|
||||
|
||||
assert.Equal(t, []*Call{c}, mockedService.ExpectedCalls)
|
||||
assert.Equal(t, 2, len(c.Arguments))
|
||||
assert.Equal(t, 1, c.Arguments[0])
|
||||
assert.Equal(t, []int{2, 3, 4}, c.Arguments[1])
|
||||
|
||||
assert.NotPanics(t, func() {
|
||||
mockedService.TheExampleMethodMixedVariadic(1, 2, 3, 4)
|
||||
})
|
||||
assert.Panics(t, func() {
|
||||
mockedService.TheExampleMethodMixedVariadic(1, 2, 3, 5)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
func Test_Mock_On_WithVariadicFuncWithInterface(t *testing.T) {
|
||||
|
||||
// make a test impl object
|
||||
@@ -726,7 +755,7 @@ func Test_AssertExpectationsForObjects_Helper(t *testing.T) {
|
||||
mockedService2.Called(2)
|
||||
mockedService3.Called(3)
|
||||
|
||||
assert.True(t, AssertExpectationsForObjects(t, mockedService1.Mock, mockedService2.Mock, mockedService3.Mock))
|
||||
assert.True(t, AssertExpectationsForObjects(t, &mockedService1.Mock, &mockedService2.Mock, &mockedService3.Mock))
|
||||
assert.True(t, AssertExpectationsForObjects(t, mockedService1, mockedService2, mockedService3))
|
||||
|
||||
}
|
||||
@@ -745,7 +774,7 @@ func Test_AssertExpectationsForObjects_Helper_Failed(t *testing.T) {
|
||||
mockedService3.Called(3)
|
||||
|
||||
tt := new(testing.T)
|
||||
assert.False(t, AssertExpectationsForObjects(tt, mockedService1.Mock, mockedService2.Mock, mockedService3.Mock))
|
||||
assert.False(t, AssertExpectationsForObjects(tt, &mockedService1.Mock, &mockedService2.Mock, &mockedService3.Mock))
|
||||
assert.False(t, AssertExpectationsForObjects(tt, mockedService1, mockedService2, mockedService3))
|
||||
|
||||
}
|
||||
@@ -1156,3 +1185,13 @@ func Test_WaitUntil_Parallel(t *testing.T) {
|
||||
// Allow the first call to execute, so the second one executes afterwards
|
||||
ch2 <- time.Now()
|
||||
}
|
||||
|
||||
func Test_MockMethodCalled(t *testing.T) {
|
||||
m := new(Mock)
|
||||
m.On("foo", "hello").Return("world")
|
||||
|
||||
retArgs := m.MethodCalled("foo", "hello")
|
||||
require.True(t, len(retArgs) == 1)
|
||||
require.Equal(t, "world", retArgs[0])
|
||||
m.AssertExpectations(t)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user