testutil

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetupTestEnums

func SetupTestEnums() *config.AuditEnums

SetupTestEnums configures enum validation for tests

func StringPtr

func StringPtr(s string) *string

StringPtr returns a pointer to the given string

Types

type MockRepository

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

MockRepository is a simple mock implementation of database.AuditRepository for testing

func NewMockRepository

func NewMockRepository() *MockRepository

NewMockRepository creates a new MockRepository instance

func (*MockRepository) ClearLogs

func (m *MockRepository) ClearLogs()

ClearLogs clears all stored logs (useful for test cleanup)

func (*MockRepository) CreateAuditLog

func (m *MockRepository) CreateAuditLog(ctx context.Context, log *v1models.AuditLog) (*v1models.AuditLog, error)

CreateAuditLog simulates creating an audit log It automatically generates an ID if not provided (simulating BeforeCreate hook behavior)

func (*MockRepository) GetAuditLogs

func (m *MockRepository) GetAuditLogs(ctx context.Context, filters *database.AuditLogFilters) ([]v1models.AuditLog, int64, error)

GetAuditLogs retrieves audit logs with optional filtering Results are ordered by timestamp DESC (newest first) and paginated

func (*MockRepository) GetAuditLogsByTraceID

func (m *MockRepository) GetAuditLogsByTraceID(ctx context.Context, traceID string) ([]v1models.AuditLog, error)

GetAuditLogsByTraceID retrieves all audit logs for a given trace ID Results are ordered by timestamp ASC (chronological order)

func (*MockRepository) GetLogs

func (m *MockRepository) GetLogs() []*v1models.AuditLog

GetLogs returns all logs stored in the mock (useful for test assertions)

Jump to

Keyboard shortcuts

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