Documentation
¶
Overview ¶
Package mock provides mock implementations of the circuitbreaking package's interfaces. Both the hand-written testify-based MockCircuitBreaker and the moq-generated CircuitBreakerMock live here during the testify → moq migration. New test code should prefer CircuitBreakerMock.
Index ¶
- type CircuitBreakerMock
- func (mock *CircuitBreakerMock) CanProceed() bool
- func (mock *CircuitBreakerMock) CanProceedCalls() []struct{}
- func (mock *CircuitBreakerMock) CannotProceed() bool
- func (mock *CircuitBreakerMock) CannotProceedCalls() []struct{}
- func (mock *CircuitBreakerMock) Failed()
- func (mock *CircuitBreakerMock) FailedCalls() []struct{}
- func (mock *CircuitBreakerMock) Succeeded()
- func (mock *CircuitBreakerMock) SucceededCalls() []struct{}
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CircuitBreakerMock ¶
type CircuitBreakerMock struct {
// CanProceedFunc mocks the CanProceed method.
CanProceedFunc func() bool
// CannotProceedFunc mocks the CannotProceed method.
CannotProceedFunc func() bool
// FailedFunc mocks the Failed method.
FailedFunc func()
// SucceededFunc mocks the Succeeded method.
SucceededFunc func()
// contains filtered or unexported fields
}
CircuitBreakerMock is a mock implementation of circuitbreaking.CircuitBreaker.
func TestSomethingThatUsesCircuitBreaker(t *testing.T) {
// make and configure a mocked circuitbreaking.CircuitBreaker
mockedCircuitBreaker := &CircuitBreakerMock{
CanProceedFunc: func() bool {
panic("mock out the CanProceed method")
},
CannotProceedFunc: func() bool {
panic("mock out the CannotProceed method")
},
FailedFunc: func() {
panic("mock out the Failed method")
},
SucceededFunc: func() {
panic("mock out the Succeeded method")
},
}
// use mockedCircuitBreaker in code that requires circuitbreaking.CircuitBreaker
// and then make assertions.
}
func (*CircuitBreakerMock) CanProceed ¶
func (mock *CircuitBreakerMock) CanProceed() bool
CanProceed calls CanProceedFunc.
func (*CircuitBreakerMock) CanProceedCalls ¶
func (mock *CircuitBreakerMock) CanProceedCalls() []struct { }
CanProceedCalls gets all the calls that were made to CanProceed. Check the length with:
len(mockedCircuitBreaker.CanProceedCalls())
func (*CircuitBreakerMock) CannotProceed ¶
func (mock *CircuitBreakerMock) CannotProceed() bool
CannotProceed calls CannotProceedFunc.
func (*CircuitBreakerMock) CannotProceedCalls ¶
func (mock *CircuitBreakerMock) CannotProceedCalls() []struct { }
CannotProceedCalls gets all the calls that were made to CannotProceed. Check the length with:
len(mockedCircuitBreaker.CannotProceedCalls())
func (*CircuitBreakerMock) Failed ¶
func (mock *CircuitBreakerMock) Failed()
Failed calls FailedFunc.
func (*CircuitBreakerMock) FailedCalls ¶
func (mock *CircuitBreakerMock) FailedCalls() []struct { }
FailedCalls gets all the calls that were made to Failed. Check the length with:
len(mockedCircuitBreaker.FailedCalls())
func (*CircuitBreakerMock) Succeeded ¶
func (mock *CircuitBreakerMock) Succeeded()
Succeeded calls SucceededFunc.
func (*CircuitBreakerMock) SucceededCalls ¶
func (mock *CircuitBreakerMock) SucceededCalls() []struct { }
SucceededCalls gets all the calls that were made to Succeeded. Check the length with:
len(mockedCircuitBreaker.SucceededCalls())