Documentation ¶
Overview ¶
Package editorfake provides a means of building a configurable fake editor executable.
It works by hooking into the entry point of the current test executable with TryMain.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New builds a new fake editor that runs the provided operations.
It returns a shell command that, when invoked, acts like a valid editor.
func TryMain ¶
func TryMain()
TryMain is the entry point for the fake editor. It runs the editor behavior if inside a fake editor environment.
Use this in TestMain before calling m.Run().
func TestMain(m *testing.M) { editortest.TryMain() os.Exit(m.Run()) }
This is a no-op if not inside a fake editor environment.
Types ¶
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option configures the behavior of a fake editor.
func DeleteFile ¶
func DeleteFile() Option
DeleteFile informs the editor to delete the file instead of writing to it.
func ExitCode ¶
ExitCode configures the exit code of the editor. This is ignored if any of the prior operations failed.
func GiveContents ¶
GiveContents tells the editor to replace the contents of the file with the given string.
func WantContents ¶
WantContents indicates that the editor should expect exactly the provided contents as input. The editor will fail with a non-zero exit code if this condition is not met.