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 ¶
- func IntParam(name string, required bool) script.Param
- func NewEngine(t *testing.T, scripts map[string]*script.Script) *script.Engine
- func Runtime(eng *script.Engine) *ghstarlark.Runtime
- func StringParam(name string, required bool) script.Param
- func SyntheticScript(name, handler string, params ...script.Param) *script.Script
- type FakeAppender
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewEngine ¶
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 ¶
StringParam is a convenience constructor for the common "required string" param.
func SyntheticScript ¶
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 ¶
func (f *FakeAppender) Append(_ context.Context, e eventstore.Event) (uint64, error)
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.