fake

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 4 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package fake provides an in-memory backend for interaction tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend struct {
	Events []backend.Event
	// contains filtered or unexported fields
}

Backend is an in-memory backend for tests and event-flow verification.

func New

func New(events ...backend.Event) *Backend

New creates a fake backend with preset events.

func NewWithOptions added in v0.2.1

func NewWithOptions(events []backend.Event, options ...Option) *Backend

NewWithOptions creates a fake backend with preset events and options.

func (*Backend) LastSession

func (b *Backend) LastSession() *Session

LastSession returns the last created session.

func (*Backend) NewSession

func (b *Backend) NewSession(_ io.Reader, _ io.Writer) (backend.Session, error)

NewSession creates a new fake session.

type Option added in v0.2.1

type Option func(*Backend)

Option configures a fake backend.

func WithSize added in v0.2.1

func WithSize(width, height int) Option

WithSize sets the fake terminal size returned by created sessions.

type Session

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

Session is an in-memory backend session.

func (*Session) Close

func (s *Session) Close() error

Close closes the session.

func (*Session) ReadEvent

func (s *Session) ReadEvent(ctx context.Context) (backend.Event, error)

ReadEvent returns the next queued event.

func (*Session) Render

func (s *Session) Render(view backend.View) error

Render stores the rendered view.

func (*Session) Size

func (s *Session) Size() (width, height int)

Size returns a fixed fake terminal size.

func (*Session) Views

func (s *Session) Views() []backend.View

Views returns all rendered views.

Jump to

Keyboard shortcuts

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