Documentation
¶
Overview ¶
Package randommock provides mock implementations of the random package's interfaces. Both the hand-written testify-based Generator and the moq-generated GeneratorMock live here during the testify → moq migration. New test code should prefer GeneratorMock.
Index ¶
- type GeneratorMock
- func (mock *GeneratorMock) GenerateBase32EncodedString(contextMoqParam context.Context, n int) (string, error)
- func (mock *GeneratorMock) GenerateBase32EncodedStringCalls() []struct{ ... }
- func (mock *GeneratorMock) GenerateBase64EncodedString(contextMoqParam context.Context, n int) (string, error)
- func (mock *GeneratorMock) GenerateBase64EncodedStringCalls() []struct{ ... }
- func (mock *GeneratorMock) GenerateHexEncodedString(ctx context.Context, length int) (string, error)
- func (mock *GeneratorMock) GenerateHexEncodedStringCalls() []struct{ ... }
- func (mock *GeneratorMock) GenerateRawBytes(contextMoqParam context.Context, n int) ([]byte, error)
- func (mock *GeneratorMock) GenerateRawBytesCalls() []struct{ ... }
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GeneratorMock ¶
type GeneratorMock struct {
// GenerateBase32EncodedStringFunc mocks the GenerateBase32EncodedString method.
GenerateBase32EncodedStringFunc func(contextMoqParam context.Context, n int) (string, error)
// GenerateBase64EncodedStringFunc mocks the GenerateBase64EncodedString method.
GenerateBase64EncodedStringFunc func(contextMoqParam context.Context, n int) (string, error)
// GenerateHexEncodedStringFunc mocks the GenerateHexEncodedString method.
GenerateHexEncodedStringFunc func(ctx context.Context, length int) (string, error)
// GenerateRawBytesFunc mocks the GenerateRawBytes method.
GenerateRawBytesFunc func(contextMoqParam context.Context, n int) ([]byte, error)
// contains filtered or unexported fields
}
GeneratorMock is a mock implementation of random.Generator.
func TestSomethingThatUsesGenerator(t *testing.T) {
// make and configure a mocked random.Generator
mockedGenerator := &GeneratorMock{
GenerateBase32EncodedStringFunc: func(contextMoqParam context.Context, n int) (string, error) {
panic("mock out the GenerateBase32EncodedString method")
},
GenerateBase64EncodedStringFunc: func(contextMoqParam context.Context, n int) (string, error) {
panic("mock out the GenerateBase64EncodedString method")
},
GenerateHexEncodedStringFunc: func(ctx context.Context, length int) (string, error) {
panic("mock out the GenerateHexEncodedString method")
},
GenerateRawBytesFunc: func(contextMoqParam context.Context, n int) ([]byte, error) {
panic("mock out the GenerateRawBytes method")
},
}
// use mockedGenerator in code that requires random.Generator
// and then make assertions.
}
func (*GeneratorMock) GenerateBase32EncodedString ¶
func (mock *GeneratorMock) GenerateBase32EncodedString(contextMoqParam context.Context, n int) (string, error)
GenerateBase32EncodedString calls GenerateBase32EncodedStringFunc.
func (*GeneratorMock) GenerateBase32EncodedStringCalls ¶
func (mock *GeneratorMock) GenerateBase32EncodedStringCalls() []struct { ContextMoqParam context.Context N int }
GenerateBase32EncodedStringCalls gets all the calls that were made to GenerateBase32EncodedString. Check the length with:
len(mockedGenerator.GenerateBase32EncodedStringCalls())
func (*GeneratorMock) GenerateBase64EncodedString ¶
func (mock *GeneratorMock) GenerateBase64EncodedString(contextMoqParam context.Context, n int) (string, error)
GenerateBase64EncodedString calls GenerateBase64EncodedStringFunc.
func (*GeneratorMock) GenerateBase64EncodedStringCalls ¶
func (mock *GeneratorMock) GenerateBase64EncodedStringCalls() []struct { ContextMoqParam context.Context N int }
GenerateBase64EncodedStringCalls gets all the calls that were made to GenerateBase64EncodedString. Check the length with:
len(mockedGenerator.GenerateBase64EncodedStringCalls())
func (*GeneratorMock) GenerateHexEncodedString ¶
func (mock *GeneratorMock) GenerateHexEncodedString(ctx context.Context, length int) (string, error)
GenerateHexEncodedString calls GenerateHexEncodedStringFunc.
func (*GeneratorMock) GenerateHexEncodedStringCalls ¶
func (mock *GeneratorMock) GenerateHexEncodedStringCalls() []struct { Ctx context.Context Length int }
GenerateHexEncodedStringCalls gets all the calls that were made to GenerateHexEncodedString. Check the length with:
len(mockedGenerator.GenerateHexEncodedStringCalls())
func (*GeneratorMock) GenerateRawBytes ¶
GenerateRawBytes calls GenerateRawBytesFunc.
func (*GeneratorMock) GenerateRawBytesCalls ¶
func (mock *GeneratorMock) GenerateRawBytesCalls() []struct { ContextMoqParam context.Context N int }
GenerateRawBytesCalls gets all the calls that were made to GenerateRawBytes. Check the length with:
len(mockedGenerator.GenerateRawBytesCalls())