testutil

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package testutil provides synthesized helpers for testing the script engine without going through Pkl compile or a full daemon. Mirrors the shape of internal/automation/testutil for consistency.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IntParam

func IntParam(name string, required bool) script.Param

IntParam is a convenience constructor for the common "required int" param.

func NewEngine

func NewEngine(t *testing.T, scripts map[string]*script.Script) *script.Engine

NewEngine constructs a script.Engine over the provided scripts using a freshly-built Starlark runtime from the starlark testutil. Pass nil scripts to build an empty engine.

func Runtime

func Runtime(eng *script.Engine) *ghstarlark.Runtime

Runtime exposes the underlying *ghstarlark.Runtime for tests that need to drive it directly (e.g. RunTestsInFile assertions). It returns the runtime the engine was constructed with.

func StringParam

func StringParam(name string, required bool) script.Param

StringParam is a convenience constructor for the common "required string" param.

func SyntheticScript

func SyntheticScript(name, handler string, params ...script.Param) *script.Script

SyntheticScript builds an in-memory *script.Script bypassing the proto/Pkl compile pipeline. Useful for engine-level tests that just need a callable script without exercising parameter validation logic.

Types

type FakeAppender

type FakeAppender struct {
	Events []eventstore.Event
	// contains filtered or unexported fields
}

FakeAppender satisfies script.EventAppender by recording every Append call.

func NewEngineWithStore

func NewEngineWithStore(t *testing.T, scripts map[string]*script.Script) (*script.Engine, *FakeAppender)

NewEngineWithStore is NewEngine but threads a synthetic event store so Call() can emit script_invoked / script_finished events for assertions.

func (*FakeAppender) Append

Append implements script.EventAppender.

func (*FakeAppender) CountByKind

func (f *FakeAppender) CountByKind(kind string) int

CountByKind returns how many events of the given kind have been appended.

func (*FakeAppender) Snapshot

func (f *FakeAppender) Snapshot() []eventstore.Event

Snapshot returns a defensive copy of recorded events.

Jump to

Keyboard shortcuts

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