testkit

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTestChunks

func CreateTestChunks(contents ...string) []*entity.Chunk

CreateTestChunks creates multiple test chunks.

func NewTestChunk

func NewTestChunk(content string, metadata map[string]interface{}) *entity.Chunk

NewTestChunk creates a new chunk for testing.

func NewTestDocument

func NewTestDocument(id, content, docType string) *entity.Document

NewTestDocument creates a new document for testing.

func NewTestPipelineState

func NewTestPipelineState() *entity.PipelineState

NewTestPipelineState creates a new pipeline state for testing.

func NewTestQuery

func NewTestQuery(text string, metadata map[string]interface{}) *entity.Query

NewTestQuery creates a new query for testing.

func WithAnswer

func WithAnswer(state *entity.PipelineState, answer string) *entity.PipelineState

WithAnswer sets the answer in the pipeline state.

func WithQuery

func WithQuery(state *entity.PipelineState, query *entity.Query) *entity.PipelineState

WithQuery sets the query in the pipeline state.

func WithRetrievedChunks

func WithRetrievedChunks(state *entity.PipelineState, chunks ...[]*entity.Chunk) *entity.PipelineState

WithRetrievedChunks sets the retrieved chunks in the pipeline state.

Types

type CountRecord

type CountRecord struct {
	Operation string
	Status    string
	Labels    map[string]string
	Time      time.Time
}

CountRecord represents a count recording.

type DurationRecord

type DurationRecord struct {
	Operation string
	Duration  time.Duration
	Labels    map[string]string
	Time      time.Time
}

DurationRecord represents a duration recording.

type LogEntry

type LogEntry struct {
	Message string
	Fields  map[string]interface{}
}

LogEntry represents a single log entry.

type MetricRecord

type MetricRecord struct {
	Name   string
	Value  float64
	Labels map[string]string
	Time   time.Time
}

MetricRecord represents a single metric recording.

type MockCollector

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

MockCollector is a testable metrics collector that records all metrics.

func NewMockCollector

func NewMockCollector() *MockCollector

NewMockCollector creates a new mock collector for testing.

func (*MockCollector) AssertCountRecorded

func (m *MockCollector) AssertCountRecorded(operation, status string) bool

AssertCountRecorded checks if a count was recorded for the given operation and status.

func (*MockCollector) AssertDurationRecorded

func (m *MockCollector) AssertDurationRecorded(operation string) bool

AssertDurationRecorded checks if a duration was recorded for the given operation.

func (*MockCollector) CountCounts

func (m *MockCollector) CountCounts() int

CountCounts returns the number of count recordings.

func (*MockCollector) CountDurations

func (m *MockCollector) CountDurations() int

CountDurations returns the number of duration recordings.

func (*MockCollector) CountValues

func (m *MockCollector) CountValues() int

CountValues returns the number of value recordings.

func (*MockCollector) GetCounts

func (m *MockCollector) GetCounts() []CountRecord

GetCounts returns all recorded count metrics.

func (*MockCollector) GetDurations

func (m *MockCollector) GetDurations() []DurationRecord

GetDurations returns all recorded duration metrics.

func (*MockCollector) GetValues

func (m *MockCollector) GetValues() []MetricRecord

GetValues returns all recorded value metrics.

func (*MockCollector) LastCountStatus

func (m *MockCollector) LastCountStatus() string

LastCountStatus returns the last recorded count status.

func (*MockCollector) LastDuration

func (m *MockCollector) LastDuration() time.Duration

LastDuration returns the last recorded duration.

func (*MockCollector) LastOperation

func (m *MockCollector) LastOperation() string

LastOperation returns the last recorded operation name.

func (*MockCollector) RecordCount

func (m *MockCollector) RecordCount(operation string, status string, labels map[string]string)

RecordCount records a count metric.

func (*MockCollector) RecordDuration

func (m *MockCollector) RecordDuration(operation string, duration time.Duration, labels map[string]string)

RecordDuration records a duration metric.

func (*MockCollector) RecordValue

func (m *MockCollector) RecordValue(metricName string, value float64, labels map[string]string)

RecordValue records a value metric.

func (*MockCollector) Reset

func (m *MockCollector) Reset()

Reset clears all recorded metrics.

func (*MockCollector) TotalDuration

func (m *MockCollector) TotalDuration(operation string) time.Duration

TotalDuration returns the total duration recorded for an operation.

type MockLogger

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

MockLogger is a testable logger implementation that records all log entries.

func NewMockLogger

func NewMockLogger() *MockLogger

NewMockLogger creates a new mock logger for testing.

func (*MockLogger) AssertErrorContains

func (m *MockLogger) AssertErrorContains(substring string) bool

AssertErrorContains checks if any error message contains the given substring.

func (*MockLogger) AssertInfoContains

func (m *MockLogger) AssertInfoContains(substring string) bool

AssertInfoContains checks if any info message contains the given substring.

func (*MockLogger) CountErrors

func (m *MockLogger) CountErrors() int

CountErrors returns the number of error messages.

func (*MockLogger) CountInfos

func (m *MockLogger) CountInfos() int

CountInfos returns the number of info messages.

func (*MockLogger) Debug

func (m *MockLogger) Debug(message string, fields ...map[string]interface{})

Debug logs a debug message and records it for testing.

func (*MockLogger) Error

func (m *MockLogger) Error(message string, err error, fields ...map[string]interface{})

Error logs an error message and records it for testing.

func (*MockLogger) GetDebugs

func (m *MockLogger) GetDebugs() []LogEntry

GetDebugs returns all recorded debug messages.

func (*MockLogger) GetErrors

func (m *MockLogger) GetErrors() []LogEntry

GetErrors returns all recorded error messages.

func (*MockLogger) GetInfos

func (m *MockLogger) GetInfos() []LogEntry

GetInfos returns all recorded info messages.

func (*MockLogger) GetWarns

func (m *MockLogger) GetWarns() []LogEntry

GetWarns returns all recorded warning messages.

func (*MockLogger) Info

func (m *MockLogger) Info(message string, fields ...map[string]interface{})

Info logs an info message and records it for testing.

func (*MockLogger) LastInfo

func (m *MockLogger) LastInfo() string

LastInfo returns the last info message.

func (*MockLogger) Reset

func (m *MockLogger) Reset()

Reset clears all recorded log entries.

func (*MockLogger) Warn

func (m *MockLogger) Warn(message string, fields ...map[string]interface{})

Warn logs a warning message and records it for testing.

Jump to

Keyboard shortcuts

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