mocks

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KVStoreMock

type KVStoreMock struct {
	// DeleteFunc mocks the Delete method.
	DeleteFunc func(ctx context.Context, key string) error

	// GetFunc mocks the Get method.
	GetFunc func(ctx context.Context, key string) ([]byte, error)

	// GetInfoFunc mocks the GetInfo method.
	GetInfoFunc func(ctx context.Context, key string) (store.KeyInfo, error)

	// GetWithFormatFunc mocks the GetWithFormat method.
	GetWithFormatFunc func(ctx context.Context, key string) ([]byte, string, error)

	// ListFunc mocks the List method.
	ListFunc func(ctx context.Context, filter enum.SecretsFilter) ([]store.KeyInfo, error)

	// SecretsEnabledFunc mocks the SecretsEnabled method.
	SecretsEnabledFunc func() bool

	// SetFunc mocks the Set method.
	SetFunc func(ctx context.Context, key string, value []byte, format string) (bool, error)

	// SetWithVersionFunc mocks the SetWithVersion method.
	SetWithVersionFunc func(ctx context.Context, key string, value []byte, format string, expectedVersion time.Time) error
	// contains filtered or unexported fields
}

KVStoreMock is a mock implementation of server.KVStore.

func TestSomethingThatUsesKVStore(t *testing.T) {

	// make and configure a mocked server.KVStore
	mockedKVStore := &KVStoreMock{
		DeleteFunc: func(ctx context.Context, key string) error {
			panic("mock out the Delete method")
		},
		GetFunc: func(ctx context.Context, key string) ([]byte, error) {
			panic("mock out the Get method")
		},
		GetInfoFunc: func(ctx context.Context, key string) (store.KeyInfo, error) {
			panic("mock out the GetInfo method")
		},
		GetWithFormatFunc: func(ctx context.Context, key string) ([]byte, string, error) {
			panic("mock out the GetWithFormat method")
		},
		ListFunc: func(ctx context.Context, filter enum.SecretsFilter) ([]store.KeyInfo, error) {
			panic("mock out the List method")
		},
		SecretsEnabledFunc: func() bool {
			panic("mock out the SecretsEnabled method")
		},
		SetFunc: func(ctx context.Context, key string, value []byte, format string) (bool, error) {
			panic("mock out the Set method")
		},
		SetWithVersionFunc: func(ctx context.Context, key string, value []byte, format string, expectedVersion time.Time) error {
			panic("mock out the SetWithVersion method")
		},
	}

	// use mockedKVStore in code that requires server.KVStore
	// and then make assertions.

}

func (*KVStoreMock) Delete

func (mock *KVStoreMock) Delete(ctx context.Context, key string) error

Delete calls DeleteFunc.

func (*KVStoreMock) DeleteCalls

func (mock *KVStoreMock) DeleteCalls() []struct {
	Ctx context.Context
	Key string
}

DeleteCalls gets all the calls that were made to Delete. Check the length with:

len(mockedKVStore.DeleteCalls())

func (*KVStoreMock) Get

func (mock *KVStoreMock) Get(ctx context.Context, key string) ([]byte, error)

Get calls GetFunc.

func (*KVStoreMock) GetCalls

func (mock *KVStoreMock) GetCalls() []struct {
	Ctx context.Context
	Key string
}

GetCalls gets all the calls that were made to Get. Check the length with:

len(mockedKVStore.GetCalls())

func (*KVStoreMock) GetInfo added in v0.8.2

func (mock *KVStoreMock) GetInfo(ctx context.Context, key string) (store.KeyInfo, error)

GetInfo calls GetInfoFunc.

func (*KVStoreMock) GetInfoCalls added in v0.8.2

func (mock *KVStoreMock) GetInfoCalls() []struct {
	Ctx context.Context
	Key string
}

GetInfoCalls gets all the calls that were made to GetInfo. Check the length with:

len(mockedKVStore.GetInfoCalls())

func (*KVStoreMock) GetWithFormat added in v0.4.0

func (mock *KVStoreMock) GetWithFormat(ctx context.Context, key string) ([]byte, string, error)

GetWithFormat calls GetWithFormatFunc.

func (*KVStoreMock) GetWithFormatCalls added in v0.4.0

func (mock *KVStoreMock) GetWithFormatCalls() []struct {
	Ctx context.Context
	Key string
}

GetWithFormatCalls gets all the calls that were made to GetWithFormat. Check the length with:

len(mockedKVStore.GetWithFormatCalls())

func (*KVStoreMock) List

func (mock *KVStoreMock) List(ctx context.Context, filter enum.SecretsFilter) ([]store.KeyInfo, error)

List calls ListFunc.

func (*KVStoreMock) ListCalls

func (mock *KVStoreMock) ListCalls() []struct {
	Ctx    context.Context
	Filter enum.SecretsFilter
}

ListCalls gets all the calls that were made to List. Check the length with:

len(mockedKVStore.ListCalls())

func (*KVStoreMock) SecretsEnabled added in v0.15.0

func (mock *KVStoreMock) SecretsEnabled() bool

SecretsEnabled calls SecretsEnabledFunc.

func (*KVStoreMock) SecretsEnabledCalls added in v0.15.0

func (mock *KVStoreMock) SecretsEnabledCalls() []struct {
}

SecretsEnabledCalls gets all the calls that were made to SecretsEnabled. Check the length with:

len(mockedKVStore.SecretsEnabledCalls())

func (*KVStoreMock) Set

func (mock *KVStoreMock) Set(ctx context.Context, key string, value []byte, format string) (bool, error)

Set calls SetFunc.

func (*KVStoreMock) SetCalls

func (mock *KVStoreMock) SetCalls() []struct {
	Ctx    context.Context
	Key    string
	Value  []byte
	Format string
}

SetCalls gets all the calls that were made to Set. Check the length with:

len(mockedKVStore.SetCalls())

func (*KVStoreMock) SetWithVersion added in v0.10.1

func (mock *KVStoreMock) SetWithVersion(ctx context.Context, key string, value []byte, format string, expectedVersion time.Time) error

SetWithVersion calls SetWithVersionFunc.

func (*KVStoreMock) SetWithVersionCalls added in v0.10.1

func (mock *KVStoreMock) SetWithVersionCalls() []struct {
	Ctx             context.Context
	Key             string
	Value           []byte
	Format          string
	ExpectedVersion time.Time
}

SetWithVersionCalls gets all the calls that were made to SetWithVersion. Check the length with:

len(mockedKVStore.SetWithVersionCalls())

type SessionStoreMock added in v0.11.0

type SessionStoreMock struct {
	// CreateSessionFunc mocks the CreateSession method.
	CreateSessionFunc func(ctx context.Context, token string, username string, expiresAt time.Time) error

	// DeleteAllSessionsFunc mocks the DeleteAllSessions method.
	DeleteAllSessionsFunc func(ctx context.Context) error

	// DeleteExpiredSessionsFunc mocks the DeleteExpiredSessions method.
	DeleteExpiredSessionsFunc func(ctx context.Context) (int64, error)

	// DeleteSessionFunc mocks the DeleteSession method.
	DeleteSessionFunc func(ctx context.Context, token string) error

	// DeleteSessionsByUsernameFunc mocks the DeleteSessionsByUsername method.
	DeleteSessionsByUsernameFunc func(ctx context.Context, username string) error

	// GetSessionFunc mocks the GetSession method.
	GetSessionFunc func(ctx context.Context, token string) (string, time.Time, error)
	// contains filtered or unexported fields
}

SessionStoreMock is a mock implementation of server.SessionStore.

func TestSomethingThatUsesSessionStore(t *testing.T) {

	// make and configure a mocked server.SessionStore
	mockedSessionStore := &SessionStoreMock{
		CreateSessionFunc: func(ctx context.Context, token string, username string, expiresAt time.Time) error {
			panic("mock out the CreateSession method")
		},
		DeleteAllSessionsFunc: func(ctx context.Context) error {
			panic("mock out the DeleteAllSessions method")
		},
		DeleteExpiredSessionsFunc: func(ctx context.Context) (int64, error) {
			panic("mock out the DeleteExpiredSessions method")
		},
		DeleteSessionFunc: func(ctx context.Context, token string) error {
			panic("mock out the DeleteSession method")
		},
		DeleteSessionsByUsernameFunc: func(ctx context.Context, username string) error {
			panic("mock out the DeleteSessionsByUsername method")
		},
		GetSessionFunc: func(ctx context.Context, token string) (string, time.Time, error) {
			panic("mock out the GetSession method")
		},
	}

	// use mockedSessionStore in code that requires server.SessionStore
	// and then make assertions.

}

func (*SessionStoreMock) CreateSession added in v0.11.0

func (mock *SessionStoreMock) CreateSession(ctx context.Context, token string, username string, expiresAt time.Time) error

CreateSession calls CreateSessionFunc.

func (*SessionStoreMock) CreateSessionCalls added in v0.11.0

func (mock *SessionStoreMock) CreateSessionCalls() []struct {
	Ctx       context.Context
	Token     string
	Username  string
	ExpiresAt time.Time
}

CreateSessionCalls gets all the calls that were made to CreateSession. Check the length with:

len(mockedSessionStore.CreateSessionCalls())

func (*SessionStoreMock) DeleteAllSessions added in v0.11.0

func (mock *SessionStoreMock) DeleteAllSessions(ctx context.Context) error

DeleteAllSessions calls DeleteAllSessionsFunc.

func (*SessionStoreMock) DeleteAllSessionsCalls added in v0.11.0

func (mock *SessionStoreMock) DeleteAllSessionsCalls() []struct {
	Ctx context.Context
}

DeleteAllSessionsCalls gets all the calls that were made to DeleteAllSessions. Check the length with:

len(mockedSessionStore.DeleteAllSessionsCalls())

func (*SessionStoreMock) DeleteExpiredSessions added in v0.11.0

func (mock *SessionStoreMock) DeleteExpiredSessions(ctx context.Context) (int64, error)

DeleteExpiredSessions calls DeleteExpiredSessionsFunc.

func (*SessionStoreMock) DeleteExpiredSessionsCalls added in v0.11.0

func (mock *SessionStoreMock) DeleteExpiredSessionsCalls() []struct {
	Ctx context.Context
}

DeleteExpiredSessionsCalls gets all the calls that were made to DeleteExpiredSessions. Check the length with:

len(mockedSessionStore.DeleteExpiredSessionsCalls())

func (*SessionStoreMock) DeleteSession added in v0.11.0

func (mock *SessionStoreMock) DeleteSession(ctx context.Context, token string) error

DeleteSession calls DeleteSessionFunc.

func (*SessionStoreMock) DeleteSessionCalls added in v0.11.0

func (mock *SessionStoreMock) DeleteSessionCalls() []struct {
	Ctx   context.Context
	Token string
}

DeleteSessionCalls gets all the calls that were made to DeleteSession. Check the length with:

len(mockedSessionStore.DeleteSessionCalls())

func (*SessionStoreMock) DeleteSessionsByUsername added in v0.12.0

func (mock *SessionStoreMock) DeleteSessionsByUsername(ctx context.Context, username string) error

DeleteSessionsByUsername calls DeleteSessionsByUsernameFunc.

func (*SessionStoreMock) DeleteSessionsByUsernameCalls added in v0.12.0

func (mock *SessionStoreMock) DeleteSessionsByUsernameCalls() []struct {
	Ctx      context.Context
	Username string
}

DeleteSessionsByUsernameCalls gets all the calls that were made to DeleteSessionsByUsername. Check the length with:

len(mockedSessionStore.DeleteSessionsByUsernameCalls())

func (*SessionStoreMock) GetSession added in v0.11.0

func (mock *SessionStoreMock) GetSession(ctx context.Context, token string) (string, time.Time, error)

GetSession calls GetSessionFunc.

func (*SessionStoreMock) GetSessionCalls added in v0.11.0

func (mock *SessionStoreMock) GetSessionCalls() []struct {
	Ctx   context.Context
	Token string
}

GetSessionCalls gets all the calls that were made to GetSession. Check the length with:

len(mockedSessionStore.GetSessionCalls())

type ValidatorMock added in v0.7.0

type ValidatorMock struct {
	// IsValidFormatFunc mocks the IsValidFormat method.
	IsValidFormatFunc func(format string) bool

	// SupportedFormatsFunc mocks the SupportedFormats method.
	SupportedFormatsFunc func() []string

	// ValidateFunc mocks the Validate method.
	ValidateFunc func(format string, value []byte) error
	// contains filtered or unexported fields
}

ValidatorMock is a mock implementation of server.Validator.

func TestSomethingThatUsesValidator(t *testing.T) {

	// make and configure a mocked server.Validator
	mockedValidator := &ValidatorMock{
		IsValidFormatFunc: func(format string) bool {
			panic("mock out the IsValidFormat method")
		},
		SupportedFormatsFunc: func() []string {
			panic("mock out the SupportedFormats method")
		},
		ValidateFunc: func(format string, value []byte) error {
			panic("mock out the Validate method")
		},
	}

	// use mockedValidator in code that requires server.Validator
	// and then make assertions.

}

func (*ValidatorMock) IsValidFormat added in v0.9.2

func (mock *ValidatorMock) IsValidFormat(format string) bool

IsValidFormat calls IsValidFormatFunc.

func (*ValidatorMock) IsValidFormatCalls added in v0.9.2

func (mock *ValidatorMock) IsValidFormatCalls() []struct {
	Format string
}

IsValidFormatCalls gets all the calls that were made to IsValidFormat. Check the length with:

len(mockedValidator.IsValidFormatCalls())

func (*ValidatorMock) SupportedFormats added in v0.9.2

func (mock *ValidatorMock) SupportedFormats() []string

SupportedFormats calls SupportedFormatsFunc.

func (*ValidatorMock) SupportedFormatsCalls added in v0.9.2

func (mock *ValidatorMock) SupportedFormatsCalls() []struct {
}

SupportedFormatsCalls gets all the calls that were made to SupportedFormats. Check the length with:

len(mockedValidator.SupportedFormatsCalls())

func (*ValidatorMock) Validate added in v0.7.0

func (mock *ValidatorMock) Validate(format string, value []byte) error

Validate calls ValidateFunc.

func (*ValidatorMock) ValidateCalls added in v0.7.0

func (mock *ValidatorMock) ValidateCalls() []struct {
	Format string
	Value  []byte
}

ValidateCalls gets all the calls that were made to Validate. Check the length with:

len(mockedValidator.ValidateCalls())

Jump to

Keyboard shortcuts

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