testutil

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 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 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.TB, repo string, name GitName, data []byte,
) string

GitCommitFile writes and commits a file, returning its absolute path

func GitRepo

func GitRepo(t testing.TB) 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.TB)

RequireGit skips the test when no git binary is on PATH

func RunGit

func RunGit(t testing.TB, 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.TB, path string, data []byte)

WriteFile writes data 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

type GitName added in v0.4.5

type GitName string

GitName is a file's name relative to the repository root

Jump to

Keyboard shortcuts

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