mocks

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type StoreMock

type StoreMock struct {
	// DeleteVersionsFunc mocks the DeleteVersions method.
	DeleteVersionsFunc func(ctx context.Context, modelType string, modelID string, versions []int) (int, error)

	// OverThresholdFunc mocks the OverThreshold method.
	OverThresholdFunc func(ctx context.Context, threshold int, limit int) ([]auditlog.ModelRef, error)

	// QueryHistoryByModelIDFunc mocks the QueryHistoryByModelID method.
	QueryHistoryByModelIDFunc func(ctx context.Context, modelType string, modelID string) ([]auditlog.AuditLog, error)

	// QueryLastByModelIDFunc mocks the QueryLastByModelID method.
	QueryLastByModelIDFunc func(ctx context.Context, modelType string, modelID string) (auditlog.AuditLog, error)

	// QueryModelByVersionFunc mocks the QueryModelByVersion method.
	QueryModelByVersionFunc func(ctx context.Context, modelType string, modelID string, ver int) (auditlog.AuditLog, error)

	// SaveFunc mocks the Save method.
	SaveFunc func(ctx context.Context, al auditlog.AuditLog) error

	// VersionsFunc mocks the Versions method.
	VersionsFunc func(ctx context.Context, modelType string, modelID string) ([]int, error)

	// WithTxFunc mocks the WithTx method.
	WithTxFunc func(tx sqlx.ExtContext) auditlog.Store
	// contains filtered or unexported fields
}

StoreMock is a mock implementation of auditlog.Store.

func TestSomethingThatUsesStore(t *testing.T) {

	// make and configure a mocked auditlog.Store
	mockedStore := &StoreMock{
		DeleteVersionsFunc: func(ctx context.Context, modelType string, modelID string, versions []int) (int, error) {
			panic("mock out the DeleteVersions method")
		},
		OverThresholdFunc: func(ctx context.Context, threshold int, limit int) ([]auditlog.ModelRef, error) {
			panic("mock out the OverThreshold method")
		},
		QueryHistoryByModelIDFunc: func(ctx context.Context, modelType string, modelID string) ([]auditlog.AuditLog, error) {
			panic("mock out the QueryHistoryByModelID method")
		},
		QueryLastByModelIDFunc: func(ctx context.Context, modelType string, modelID string) (auditlog.AuditLog, error) {
			panic("mock out the QueryLastByModelID method")
		},
		QueryModelByVersionFunc: func(ctx context.Context, modelType string, modelID string, ver int) (auditlog.AuditLog, error) {
			panic("mock out the QueryModelByVersion method")
		},
		SaveFunc: func(ctx context.Context, al auditlog.AuditLog) error {
			panic("mock out the Save method")
		},
		VersionsFunc: func(ctx context.Context, modelType string, modelID string) ([]int, error) {
			panic("mock out the Versions method")
		},
		WithTxFunc: func(tx sqlx.ExtContext) auditlog.Store {
			panic("mock out the WithTx method")
		},
	}

	// use mockedStore in code that requires auditlog.Store
	// and then make assertions.

}

func (*StoreMock) DeleteVersions

func (mock *StoreMock) DeleteVersions(ctx context.Context, modelType string, modelID string, versions []int) (int, error)

DeleteVersions calls DeleteVersionsFunc.

func (*StoreMock) DeleteVersionsCalls

func (mock *StoreMock) DeleteVersionsCalls() []struct {
	Ctx       context.Context
	ModelType string
	ModelID   string
	Versions  []int
}

DeleteVersionsCalls gets all the calls that were made to DeleteVersions. Check the length with:

len(mockedStore.DeleteVersionsCalls())

func (*StoreMock) OverThreshold

func (mock *StoreMock) OverThreshold(ctx context.Context, threshold int, limit int) ([]auditlog.ModelRef, error)

OverThreshold calls OverThresholdFunc.

func (*StoreMock) OverThresholdCalls

func (mock *StoreMock) OverThresholdCalls() []struct {
	Ctx       context.Context
	Threshold int
	Limit     int
}

OverThresholdCalls gets all the calls that were made to OverThreshold. Check the length with:

len(mockedStore.OverThresholdCalls())

func (*StoreMock) QueryHistoryByModelID

func (mock *StoreMock) QueryHistoryByModelID(ctx context.Context, modelType string, modelID string) ([]auditlog.AuditLog, error)

QueryHistoryByModelID calls QueryHistoryByModelIDFunc.

func (*StoreMock) QueryHistoryByModelIDCalls

func (mock *StoreMock) QueryHistoryByModelIDCalls() []struct {
	Ctx       context.Context
	ModelType string
	ModelID   string
}

QueryHistoryByModelIDCalls gets all the calls that were made to QueryHistoryByModelID. Check the length with:

len(mockedStore.QueryHistoryByModelIDCalls())

func (*StoreMock) QueryLastByModelID

func (mock *StoreMock) QueryLastByModelID(ctx context.Context, modelType string, modelID string) (auditlog.AuditLog, error)

QueryLastByModelID calls QueryLastByModelIDFunc.

func (*StoreMock) QueryLastByModelIDCalls

func (mock *StoreMock) QueryLastByModelIDCalls() []struct {
	Ctx       context.Context
	ModelType string
	ModelID   string
}

QueryLastByModelIDCalls gets all the calls that were made to QueryLastByModelID. Check the length with:

len(mockedStore.QueryLastByModelIDCalls())

func (*StoreMock) QueryModelByVersion

func (mock *StoreMock) QueryModelByVersion(ctx context.Context, modelType string, modelID string, ver int) (auditlog.AuditLog, error)

QueryModelByVersion calls QueryModelByVersionFunc.

func (*StoreMock) QueryModelByVersionCalls

func (mock *StoreMock) QueryModelByVersionCalls() []struct {
	Ctx       context.Context
	ModelType string
	ModelID   string
	Ver       int
}

QueryModelByVersionCalls gets all the calls that were made to QueryModelByVersion. Check the length with:

len(mockedStore.QueryModelByVersionCalls())

func (*StoreMock) Save

func (mock *StoreMock) Save(ctx context.Context, al auditlog.AuditLog) error

Save calls SaveFunc.

func (*StoreMock) SaveCalls

func (mock *StoreMock) SaveCalls() []struct {
	Ctx context.Context
	Al  auditlog.AuditLog
}

SaveCalls gets all the calls that were made to Save. Check the length with:

len(mockedStore.SaveCalls())

func (*StoreMock) Versions

func (mock *StoreMock) Versions(ctx context.Context, modelType string, modelID string) ([]int, error)

Versions calls VersionsFunc.

func (*StoreMock) VersionsCalls

func (mock *StoreMock) VersionsCalls() []struct {
	Ctx       context.Context
	ModelType string
	ModelID   string
}

VersionsCalls gets all the calls that were made to Versions. Check the length with:

len(mockedStore.VersionsCalls())

func (*StoreMock) WithTx

func (mock *StoreMock) WithTx(tx sqlx.ExtContext) auditlog.Store

WithTx calls WithTxFunc.

func (*StoreMock) WithTxCalls

func (mock *StoreMock) WithTxCalls() []struct {
	Tx sqlx.ExtContext
}

WithTxCalls gets all the calls that were made to WithTx. Check the length with:

len(mockedStore.WithTxCalls())

Jump to

Keyboard shortcuts

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