testutil

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 StatusMsg added in v0.3.0

func StatusMsg(e *view.Editor) string

StatusMsg drains the queued status messages as one newline-joined string

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