testcli

package module
Version: v0.0.0-...-ddd2d1f Latest Latest
Warning

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

Go to latest
Published: May 28, 2021 License: MIT Imports: 6 Imported by: 0

README

go-testcli

Go Reference

Go package containing helpers for testing CLIs.

Usage

Define your main function so that it matches the signature of testcli.MainFunc. In tests, call your main function using testcli.Main which will capture stdout, stderr, and the exit code. Use the other helper functions to create a working directory that suites the use cases that need testing.

For an example of this used in the wild, see the tests of gas.

Documentation

Overview

Define your main function so that it matches the signature of testcli.MainFunc. In tests, call your main function using testcli.Main which will capture stdout, stderr, and the exit code. Use the other helper functions to create a working directory that suites the use cases that need testing.

For an example of this used in the wild, see the tests of gas: https://4d63.com/gas

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chdir

func Chdir(t testing.TB, dir string)

func Exec

func Exec(t testing.TB, command string) (exitCode int, stdout, stderr string)

func Main

func Main(t testing.TB, args []string, stdin io.Reader, main MainFunc) (exitCode int, stdout, stderr string)

func Mkdir

func Mkdir(t testing.TB, path string)

func MkdirTemp

func MkdirTemp(t testing.TB) string

func WriteFile

func WriteFile(t testing.TB, filename string, data []byte)

Types

type MainFunc

type MainFunc func(args []string, stdin io.Reader, stdout, stderr io.Writer) int

Source Files

Jump to

Keyboard shortcuts

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