mdktest

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ProjectorModule

type ProjectorModule struct {
	ModuleID string
	Proj     mdk.Projector
}

ProjectorModule is a generic mock implementation of a module that provides a Projector.

func (*ProjectorModule) ID

func (pm *ProjectorModule) ID() string

ID returns the module ID, defaulting to "core.context".

func (*ProjectorModule) Init

func (pm *ProjectorModule) Init(ctx context.Context, rt mdk.Runtime) error

func (*ProjectorModule) Models

func (pm *ProjectorModule) Models() []any

func (*ProjectorModule) Projector

func (pm *ProjectorModule) Projector() mdk.Projector

func (*ProjectorModule) Routes

func (pm *ProjectorModule) Routes() []mdk.Route

func (*ProjectorModule) Shutdown

func (pm *ProjectorModule) Shutdown(ctx context.Context) error

type TestEventBus

type TestEventBus struct {
	Published []mdk.Event
	// contains filtered or unexported fields
}

TestEventBus is an in-memory implementation of EventBus for testing.

func NewTestEventBus

func NewTestEventBus(rt *TestRuntime) *TestEventBus

func (*TestEventBus) Publish

func (teb *TestEventBus) Publish(ctx context.Context, e mdk.Event) error

func (*TestEventBus) Subscribe

func (teb *TestEventBus) Subscribe(namespace, eventType string, handler mdk.EventHandler) (func(), error)

type TestLineageData

type TestLineageData struct {
	ID        string
	Name      string
	State     string
	Error     string
	StartedAt time.Time
	EndedAt   *time.Time
	Events    []mdk.Event
}

TestLineageData implements LineageData for testing.

func (TestLineageData) GetEndedAt

func (tld TestLineageData) GetEndedAt() *time.Time

func (TestLineageData) GetError

func (tld TestLineageData) GetError() string

func (TestLineageData) GetEvents

func (tld TestLineageData) GetEvents() []mdk.Event

func (TestLineageData) GetID

func (tld TestLineageData) GetID() string

func (TestLineageData) GetName

func (tld TestLineageData) GetName() string

func (TestLineageData) GetStartedAt

func (tld TestLineageData) GetStartedAt() time.Time

func (TestLineageData) GetState

func (tld TestLineageData) GetState() string

type TestProjector

type TestProjector struct {
	Lineages []mdk.LineageData
}

TestProjector implements Projector for testing.

func (*TestProjector) ListLineages

func (tp *TestProjector) ListLineages() []mdk.LineageData

func (*TestProjector) QueryLineages

func (tp *TestProjector) QueryLineages(filter func(mdk.LineageData) bool) []mdk.LineageData

type TestRuntime

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

TestRuntime is a concrete, in-memory implementation of Runtime designed for unit testing.

func NewTestRuntime

func NewTestRuntime(db *gorm.DB) *TestRuntime

NewTestRuntime creates a new TestRuntime instance.

func (*TestRuntime) Bus

func (tr *TestRuntime) Bus() mdk.EventBus

func (*TestRuntime) Config

func (tr *TestRuntime) Config(key string) any

func (*TestRuntime) DB

func (tr *TestRuntime) DB() *gorm.DB

func (*TestRuntime) Logger

func (tr *TestRuntime) Logger() *slog.Logger

func (*TestRuntime) Module

func (tr *TestRuntime) Module(id string) (mdk.Module, bool)

func (*TestRuntime) SetConfig

func (tr *TestRuntime) SetConfig(key string, val any)

func (*TestRuntime) SetLogger

func (tr *TestRuntime) SetLogger(l *slog.Logger)

func (*TestRuntime) SetModule

func (tr *TestRuntime) SetModule(id string, m mdk.Module)

func (*TestRuntime) Workflows

func (tr *TestRuntime) Workflows() mdk.WorkflowEngine

type TestWorkflowEngine

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

TestWorkflowEngine is a simple, synchronous implementation of WorkflowEngine for unit tests.

func NewTestWorkflowEngine

func NewTestWorkflowEngine(rt *TestRuntime) *TestWorkflowEngine

func (*TestWorkflowEngine) Cancel

func (twe *TestWorkflowEngine) Cancel(ctx context.Context, runID string) error

func (*TestWorkflowEngine) Execute

func (twe *TestWorkflowEngine) Execute(ctx context.Context, workflowID string, input map[string]any) (string, error)

func (*TestWorkflowEngine) ExecuteSync

func (twe *TestWorkflowEngine) ExecuteSync(ctx context.Context, runID, workflowID string, input map[string]any) (map[string]any, error)

func (*TestWorkflowEngine) Register

func (twe *TestWorkflowEngine) Register(w mdk.Workflow) error

func (*TestWorkflowEngine) RegisterHandler

func (twe *TestWorkflowEngine) RegisterHandler(name string, handler mdk.StepHandler) error

func (*TestWorkflowEngine) Status

func (twe *TestWorkflowEngine) Status(ctx context.Context, runID string) (mdk.StepStatus, error)

Jump to

Keyboard shortcuts

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