Documentation
¶
Overview ¶
Package fake is a scriptable harness.Adapter for pipeline and worker tests (harness-adapters.md §Fake adapter): scripted progress, usage and results, a scripted repair turn, and ways to simulate a rate limit or a run that only ends when it's stopped.
Index ¶
- Constants
- type Adapter
- func (a *Adapter) Capabilities() v1alpha1.AdapterCapabilities
- func (a *Adapter) Name() string
- func (a *Adapter) Prepare(_ context.Context, ws harness.Workspace, _ v1alpha1.Task) error
- func (a *Adapter) Prepared() []harness.Workspace
- func (a *Adapter) Problems() [][]string
- func (a *Adapter) Prompts() []string
- func (a *Adapter) Repair(ctx context.Context, ws harness.Workspace, problems []string, ...) (harness.Raw, error)
- func (a *Adapter) Run(ctx context.Context, ws harness.Workspace, _ v1alpha1.Task, prompt string, ...) (harness.Raw, error)
- type Script
- type Turn
Constants ¶
View Source
const Name = "fake"
Name is the fake harness's default name.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
// HarnessName is Name() (default "fake").
HarnessName string
Script Script
// contains filtered or unexported fields
}
Adapter is the fake harness. It records what it was given; safe for concurrent use.
func (*Adapter) Capabilities ¶
func (a *Adapter) Capabilities() v1alpha1.AdapterCapabilities
Capabilities implements harness.Adapter.
type Script ¶
type Script struct {
Turn
// PrepareErr is returned by Prepare.
PrepareErr error
// Repairs are the successive Repair turns; a Repair beyond them writes nothing.
Repairs []Turn
}
Script is the whole fake run: the Run turn and the repair turns, in order.
type Turn ¶
type Turn struct {
// Events and Usage are reported to the sink in order (Usage after Events).
Events []harness.ProgressEvent
Usage []harness.UsageDelta
// Result, when non-nil, is written to the workspace's $FACTORY_RESULT file.
Result []byte
// Output is returned as Raw.Result (the harness's structured output).
Output []byte
// Transcript lines are returned as Raw.Transcript.
Transcript []string
// Err is returned after the turn.
Err error
// RateLimitAfter > 0 reports RateLimited(RateLimitUntil) after that many events and
// then waits for ctx to end.
RateLimitAfter int
RateLimitUntil time.Time
// Block waits for ctx to end after the events (a run only a limit stops).
Block bool
// Do runs before the events, with the workspace and the prompt ("" for a repair); an
// error ends the turn with it.
Do func(ctx context.Context, ws harness.Workspace, prompt string) error
}
Turn is one scripted Run or Repair.
Click to show internal directories.
Click to hide internal directories.