randommock

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2026 License: AGPL-3.0 Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

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

func (mock *GeneratorMock) GenerateRawBytes(contextMoqParam context.Context, n int) ([]byte, error)

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())

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL