ptytest

package
v0.9.28 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package ptytest provides test-only PTY cassette scenario assertions.

Index

Constants

View Source
const (
	ReplayRealtime  = cassette.ReplayRealtime
	ReplayScaled    = cassette.ReplayScaled
	ReplayCollapsed = cassette.ReplayCollapsed
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AssertionSpec

type AssertionSpec struct {
	Name          string  `json:"name,omitempty" yaml:"name,omitempty"`
	Type          string  `json:"type" yaml:"type"`
	AtMS          *int64  `json:"at_ms,omitempty" yaml:"at_ms,omitempty"`
	WithinMS      int64   `json:"within_ms,omitempty" yaml:"within_ms,omitempty"`
	StableForMS   int64   `json:"stable_for_ms,omitempty" yaml:"stable_for_ms,omitempty"`
	Text          string  `json:"text,omitempty" yaml:"text,omitempty"`
	BytesHex      string  `json:"bytes_hex,omitempty" yaml:"bytes_hex,omitempty"`
	Key           string  `json:"key,omitempty" yaml:"key,omitempty"`
	Rows          int     `json:"rows,omitempty" yaml:"rows,omitempty"`
	Cols          int     `json:"cols,omitempty" yaml:"cols,omitempty"`
	CursorRow     int     `json:"cursor_row,omitempty" yaml:"cursor_row,omitempty"`
	CursorCol     int     `json:"cursor_col,omitempty" yaml:"cursor_col,omitempty"`
	CursorVisible *bool   `json:"cursor_visible,omitempty" yaml:"cursor_visible,omitempty"`
	FG            *uint32 `json:"fg,omitempty" yaml:"fg,omitempty"`
	BG            *uint32 `json:"bg,omitempty" yaml:"bg,omitempty"`
	JSONPath      string  `json:"json_path,omitempty" yaml:"json_path,omitempty"`
	Equals        any     `json:"equals,omitempty" yaml:"equals,omitempty"`
	MetadataKey   string  `json:"metadata_key,omitempty" yaml:"metadata_key,omitempty"`
	ExitCode      *int    `json:"exit_code,omitempty" yaml:"exit_code,omitempty"`
	Signaled      *bool   `json:"signaled,omitempty" yaml:"signaled,omitempty"`
	Kind          string  `json:"kind,omitempty" yaml:"kind,omitempty"`
	BeforeKind    string  `json:"before_kind,omitempty" yaml:"before_kind,omitempty"`
	AfterKind     string  `json:"after_kind,omitempty" yaml:"after_kind,omitempty"`
	MinMS         *int64  `json:"min_ms,omitempty" yaml:"min_ms,omitempty"`
	MaxMS         *int64  `json:"max_ms,omitempty" yaml:"max_ms,omitempty"`
}

type EnvironmentPolicy

type EnvironmentPolicy struct {
	Home       string            `json:"home,omitempty" yaml:"home,omitempty"`
	ConfigRoot string            `json:"config_root,omitempty" yaml:"config_root,omitempty"`
	Allowlist  []string          `json:"allowlist,omitempty" yaml:"allowlist,omitempty"`
	Variables  map[string]string `json:"variables,omitempty" yaml:"variables,omitempty"`
}

type Failure

type Failure struct {
	Group          string
	Assertion      AssertionSpec
	Message        string
	NearestTMS     int64
	ScreenExcerpt  string
	ServiceContext string
}

func (Failure) Error

func (f Failure) Error() string

type ReplayMode

type ReplayMode = cassette.ReplayMode

type Result

type Result struct {
	Scenario    Scenario
	Manifest    cassette.Manifest
	Events      []cassette.Event
	Failures    []Failure
	Clock       *VirtualClock
	Artifacts   map[string]string
	Environment map[string]string
}

func RunScenario

func RunScenario(ctx context.Context, scenario Scenario) (Result, error)

type Scenario

type Scenario struct {
	Name                  string                     `json:"name" yaml:"name"`
	CassettePath          string                     `json:"cassette_path" yaml:"cassette_path"`
	ExpectedManifestID    string                     `json:"expected_manifest_id" yaml:"expected_manifest_id"`
	ExpectedContentDigest string                     `json:"expected_content_digest" yaml:"expected_content_digest"`
	RequiredEmulator      *cassette.Emulator         `json:"required_emulator,omitempty" yaml:"required_emulator,omitempty"`
	ReplayMode            ReplayMode                 `json:"replay_mode" yaml:"replay_mode"`
	ReplayScale           float64                    `json:"replay_scale,omitempty" yaml:"replay_scale,omitempty"`
	TerminalSize          *TerminalSize              `json:"terminal_size,omitempty" yaml:"terminal_size,omitempty"`
	Environment           EnvironmentPolicy          `json:"environment,omitempty" yaml:"environment,omitempty"`
	ExpectedArtifacts     []string                   `json:"expected_artifacts,omitempty" yaml:"expected_artifacts,omitempty"`
	ResolutionMS          int64                      `json:"resolution_ms,omitempty" yaml:"resolution_ms,omitempty"`
	Groups                map[string][]AssertionSpec `json:"groups" yaml:"groups"`
}

func LoadScenario

func LoadScenario(path string) (Scenario, error)

type TerminalSize

type TerminalSize struct {
	Rows int `json:"rows" yaml:"rows"`
	Cols int `json:"cols" yaml:"cols"`
}

type VirtualClock

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

func NewVirtualClock

func NewVirtualClock() *VirtualClock

func (*VirtualClock) Advance

func (v *VirtualClock) Advance(d time.Duration)

func (*VirtualClock) NowMS

func (v *VirtualClock) NowMS() int64

func (*VirtualClock) Set

func (v *VirtualClock) Set(ms int64)

Jump to

Keyboard shortcuts

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