testutil

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2025 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxWaitRetry   = 300
	DefaultPostWaitPeriod = 5 * time.Second
	GasStationMnemonic    = "imitate sick vibrant bonus weather spice pave announce direct impulse strategy math"
)

Variables

View Source
var (
	PressEnter = InputStep{Msg: tea.KeyMsg{Type: tea.KeyEnter}}
	PressSpace = InputStep{Msg: tea.KeyMsg{Type: tea.KeySpace}}
	PressTab   = InputStep{Msg: tea.KeyMsg{Type: tea.KeyTab}}
	PressUp    = InputStep{Msg: tea.KeyMsg{Type: tea.KeyUp}}
	PressDown  = InputStep{Msg: tea.KeyMsg{Type: tea.KeyDown}}

	WaitFetching = WaitStep{Check: func() bool {
		time.Sleep(5 * time.Second)
		return true
	}}
)

Functions

func ClearTestDir

func ClearTestDir(dir string)

func CompareJsonValue

func CompareJsonValue(t *testing.T, filePath, key string, expectedValue interface{})

func CompareTomlValue

func CompareTomlValue(t *testing.T, filePath, key string, expectedValue interface{})

func GetJsonValue

func GetJsonValue(filePath, key string) (interface{}, error)

func GetTomlValue

func GetTomlValue(filePath, key string) (interface{}, error)

func RunProgramWithSteps

func RunProgramWithSteps(t *testing.T, program tea.Model, steps Steps) tea.Model

func SetupGasStation

func SetupGasStation(t *testing.T) tea.Model

Types

type InputStep

type InputStep struct {
	Msg tea.Msg
}

func TypeText

func TypeText(text string) InputStep

func (InputStep) Execute

func (i InputStep) Execute(prog tea.Program)

func (InputStep) Wait

func (i InputStep) Wait() bool

type Step

type Step interface {
	Execute(prog tea.Program)
	Wait() bool
}

type Steps

type Steps []Step

type WaitStep

type WaitStep struct {
	Check func() bool
}

func WaitFor

func WaitFor(waitCondition func() bool) WaitStep

WaitFor receives waitCondition as a parameter, which should return true if the wait should be over.

func (WaitStep) Execute

func (w WaitStep) Execute(_ tea.Program)

func (WaitStep) Wait

func (w WaitStep) Wait() bool

Jump to

Keyboard shortcuts

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