mockedit

package
v0.1.0-beta6 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package mockedit provides a mock implementation of an editor. It's a a simple process controlled with environment variables:

  • MOCKEDIT_GIVE: Specifies the path to a file that contains the contents to write for an edit operation. This is required.
  • MOCKEDIT_RECORD: Specifies the path to a file where contents of an edited file should be written. This is optional.

The process expects the path to a file to edit as its only argument.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Main

func Main() (exitCode int)

Main runs the mock editor and exits the process. Usage:

mockedit <file>

mockedit writes the contents of MOCKEDIT_GIVE into the given file. If MOCKEDIT_GIVE is not set, the file is returned unchanged. If MOCKEDIT_RECORD is set, it will also copy the contents of <file> into it.

If both MOCKEDIT_GIVE and MOCKEDIT_RECORD are unset, mockedit will fail.

Types

type Handle

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

Handle controls the behavior of the mock editor.

func Expect

func Expect(t testing.TB) *Handle

Expect tells mockedit to expect a new edit operation.

By default, following an Expect call, mockedit will write back the file unchanged.

Use Give to specify the contents to write back.

func (*Handle) Give

func (e *Handle) Give(contents string) *Handle

Give tells mockedit to write the given contents back for the next edit operation.

func (*Handle) GiveLines

func (e *Handle) GiveLines(lines ...string) *Handle

GiveLines is a convenience method to give multiple lines of contents.

func (*Handle) Got

func (e *Handle) Got() string

Got reports the contents of the recorded file. This must be called only after an edit operation.

Jump to

Keyboard shortcuts

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