testutil

package
v0.1.38 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: MIT Imports: 9 Imported by: 0 modules, 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Char

func Char(ch rune) command.KeyEvent

Char builds a KeyEvent for a printable character

func CursorPos

func CursorPos(t *testing.T, e *view.Editor) int

CursorPos returns the cursor position in the focused document

func EditorWithText

func EditorWithText(t *testing.T, text string) *view.Editor

EditorWithText creates an editor seeded with text and the cursor at pos 0

func GitCommitFile

func GitCommitFile(t *testing.T, repo, name, content string) string

GitCommitFile writes and commits a file, returning its absolute path

func GitRepo

func GitRepo(t *testing.T) string

GitRepo creates a temporary git repository with commit identity configured

func RegisteredValue

func RegisteredValue(t *testing.T, e *view.Editor, reg rune) string

RegisteredValue returns the first value stored in the named register

func RequireGit

func RequireGit(t *testing.T)

RequireGit skips the test when no git binary is on PATH

func RunGit

func RunGit(t *testing.T, dir string, args ...string)

RunGit runs a git command in dir, failing the test on error

func SetCursor

func SetCursor(t *testing.T, e *view.Editor, pos int)

SetCursor moves the focused view's cursor to pos

func SetEditorText

func SetEditorText(t *testing.T, e *view.Editor, text string)

SetEditorText inserts text into an existing editor's focused document

func SetSelection

func SetSelection(
	t *testing.T, e *view.Editor, ranges []core.Range, primary int,
)

SetSelection replaces the focused view's selection

func Special

func Special(s command.Special) command.KeyEvent

Special builds a KeyEvent for a special key

func WriteFile

func WriteFile(t *testing.T, path, content string)

WriteFile writes content to path, failing the test on error

Types

type FakeClipboard

type FakeClipboard struct {
	System  string
	Primary string
	Ready   bool
}

FakeClipboard is an in-memory view.Clipboard for hermetic tests, keeping the system and PRIMARY selections in separate buffers

func NewFakeClipboard

func NewFakeClipboard() *FakeClipboard

NewFakeClipboard returns an in-memory clipboard for tests

func (*FakeClipboard) Available

func (c *FakeClipboard) Available() bool

Available always reports true

func (*FakeClipboard) Read

func (c *FakeClipboard) Read() (string, error)

Read returns the stored clipboard contents

func (*FakeClipboard) ReadPrimary

func (c *FakeClipboard) ReadPrimary() (string, error)

ReadPrimary returns the stored primary selection

func (*FakeClipboard) Write

func (c *FakeClipboard) Write(text string) error

Write stores text as the clipboard contents

func (*FakeClipboard) WritePrimary

func (c *FakeClipboard) WritePrimary(text string) error

WritePrimary stores text as the primary selection

Jump to

Keyboard shortcuts

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