testutils

package
v1.59.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package testutils is a generated GoMock package.

Index

Constants

View Source
const RFC3339Regex = "" // nolint:lll

/* 161-byte string literal not displayed */

Variables

View Source
var FlagKeyNotStringResult = MissingFlagKeyResult
View Source
var MissingFlagKeyResult = `` /* 216-byte string literal not displayed */
View Source
var MongoFindResultFlagNoStr = `` /* 440-byte string literal not displayed */
View Source
var MongoFindResultString = `` /* 445-byte string literal not displayed */
View Source
var MongoMissingFlagKey = `` /* 425-byte string literal not displayed */
View Source
var QueryResult = `` /* 431-byte string literal not displayed */

Functions

func CopyContentToExistingTempFile added in v1.50.0

func CopyContentToExistingTempFile(t *testing.T, content string, file *os.File) *os.File

func CopyContentToNewTempFile added in v1.50.0

func CopyContentToNewTempFile(t *testing.T, content string) *os.File

func CopyFileToExistingTempFile added in v1.50.0

func CopyFileToExistingTempFile(t *testing.T, src string, file *os.File) *os.File

func CopyFileToNewTempFile added in v1.50.0

func CopyFileToNewTempFile(t *testing.T, src string) *os.File

func EncodedMd5Hash added in v1.48.0

func EncodedMd5Hash(content []byte) string

func GetFreePort added in v1.50.0

func GetFreePort(t *testing.T) int

GetFreePort returns a free port on the local machine.

func GetFreePortAsString added in v1.50.0

func GetFreePortAsString(t *testing.T) string

GetFreePortAsString returns a free port on the local machine as a string.

func ReplaceAndCopyFileToExistingFile added in v1.50.0

func ReplaceAndCopyFileToExistingFile(t *testing.T, src string, dstFile *os.File, old, newStr string) *os.File

func ReplaceInFile added in v1.50.0

func ReplaceInFile(t *testing.T, file *os.File, old, newStr string)

Types

type ExportableMockEvent added in v1.44.0

type ExportableMockEvent struct {
	// contains filtered or unexported fields
}

func NewExportableMockEvent added in v1.44.0

func NewExportableMockEvent(name string) ExportableMockEvent

func (ExportableMockEvent) FormatInCSV added in v1.44.0

func (e ExportableMockEvent) FormatInCSV(_ *template.Template) ([]byte, error)

func (ExportableMockEvent) FormatInJSON added in v1.44.0

func (e ExportableMockEvent) FormatInJSON() ([]byte, error)

func (ExportableMockEvent) GetCreationDate added in v1.44.0

func (e ExportableMockEvent) GetCreationDate() int64

func (ExportableMockEvent) GetKey added in v1.44.0

func (e ExportableMockEvent) GetKey() string

func (ExportableMockEvent) GetUserKey added in v1.44.0

func (e ExportableMockEvent) GetUserKey() string

type GCStorageReaderMock added in v0.19.0

type GCStorageReaderMock struct {
	ShouldFail bool
	FileToRead string
	// contains filtered or unexported fields
}

func (*GCStorageReaderMock) Close added in v0.19.0

func (r *GCStorageReaderMock) Close() error

func (*GCStorageReaderMock) Read added in v0.19.0

func (r *GCStorageReaderMock) Read(p []byte) (n int, err error)

type HTTPClientMock added in v0.13.0

type HTTPClientMock struct {
	ForceError bool
	StatusCode int
	Body       string
	Signature  string
	Headers    map[string][]string
}

func (*HTTPClientMock) Do added in v0.13.0

func (h *HTTPClientMock) Do(req *http.Request) (*http.Response, error)

type MockedStorage added in v1.48.0

type MockedStorage struct {
	Server *fakestorage.Server
}

func NewMockedGCS added in v1.48.0

func NewMockedGCS(t *testing.T) MockedStorage

func (MockedStorage) WithFiles added in v1.48.0

func (m MockedStorage) WithFiles(t *testing.T, bucketName string, files map[string]string)

type Mockobject added in v0.19.0

type Mockobject struct {
	// contains filtered or unexported fields
}

Mockobject is a mock of object interface.

func NewMockobject added in v0.19.0

func NewMockobject(ctrl *gomock.Controller) *Mockobject

NewMockobject creates a new mock instance.

func (*Mockobject) Attrs added in v0.19.0

func (m *Mockobject) Attrs(ctx context.Context) (*storage.ObjectAttrs, error)

Attrs mocks base method.

func (*Mockobject) EXPECT added in v0.19.0

func (m *Mockobject) EXPECT() *MockobjectMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*Mockobject) NewReader added in v0.19.0

func (m *Mockobject) NewReader(ctx context.Context) (*storage.Reader, error)

NewReader mocks base method.

type MockobjectMockRecorder added in v0.19.0

type MockobjectMockRecorder struct {
	// contains filtered or unexported fields
}

MockobjectMockRecorder is the mock recorder for Mockobject.

func (*MockobjectMockRecorder) Attrs added in v0.19.0

func (mr *MockobjectMockRecorder) Attrs(ctx any) *gomock.Call

Attrs indicates an expected call of Attrs.

func (*MockobjectMockRecorder) NewReader added in v0.19.0

func (mr *MockobjectMockRecorder) NewReader(ctx any) *gomock.Call

NewReader indicates an expected call of NewReader.

type S3ManagerV2Mock added in v1.15.0

type S3ManagerV2Mock struct {
	S3ManagerMockFileSystem map[string]string
	TestDataLocation        string
}

func (*S3ManagerV2Mock) DownloadObject added in v1.51.1

func (*S3ManagerV2Mock) UploadObject added in v1.51.1

type S3PrefixMock added in v1.58.0

type S3PrefixMock struct {
	// PageSize is the max number of keys returned by one ListObjectsV2 call (default 1000).
	PageSize int
	// ListErr, if set, is returned by every ListObjectsV2 call.
	ListErr error
	// DownloadErr, if set, is returned by every DownloadObject call.
	DownloadErr error
	// NoETag lists the objects with an empty ETag, like some S3 compatible stores do.
	NoETag bool
	// BeforeDownload, if set, is called with the key at the start of every DownloadObject call,
	// without the mock lock held, so it can call Put and Delete to swap an object between the list
	// and the download.
	BeforeDownload func(key string)
	// contains filtered or unexported fields
}

S3PrefixMock is an in-memory fake of a S3 bucket implementing both the lister and the downloader APIs used by the S3 retriever v2. It supports prefix/delimiter semantics, pagination, ETags and call counters.

func (*S3PrefixMock) Delete added in v1.58.0

func (m *S3PrefixMock) Delete(key string)

Delete removes an object.

func (*S3PrefixMock) DownloadCalls added in v1.58.0

func (m *S3PrefixMock) DownloadCalls(key string) int

DownloadCalls returns the number of times the key was downloaded.

func (*S3PrefixMock) DownloadObject added in v1.58.0

DownloadObject writes the content of the object in the WriterAt of the input.

func (*S3PrefixMock) ListCalls added in v1.58.0

func (m *S3PrefixMock) ListCalls() int

ListCalls returns the number of ListObjectsV2 calls.

func (*S3PrefixMock) ListObjectsV2 added in v1.58.0

func (m *S3PrefixMock) ListObjectsV2(
	_ context.Context,
	params *s3.ListObjectsV2Input,
	_ ...func(*s3.Options),
) (*s3.ListObjectsV2Output, error)

ListObjectsV2 mimics the S3 API (prefix, delimiter, continuation token, max keys).

func (*S3PrefixMock) Put added in v1.58.0

func (m *S3PrefixMock) Put(key, content string)

Put creates or replaces an object. The ETag is derived from the content.

func (*S3PrefixMock) SetDownloadErrKey added in v1.58.0

func (m *S3PrefixMock) SetDownloadErrKey(key string, err error)

SetDownloadErrKey makes the download of one key fail with err, nil removes the failure.

func (*S3PrefixMock) TotalDownloadCalls added in v1.58.0

func (m *S3PrefixMock) TotalDownloadCalls() int

TotalDownloadCalls returns the number of downloads, all keys included.

Directories

Path Synopsis
mockretriever
Package mockretriever provides mock implementations of various retriever interfaces for testing purposes in the go-feature-flag project.
Package mockretriever provides mock implementations of various retriever interfaces for testing purposes in the go-feature-flag project.

Jump to

Keyboard shortcuts

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