test

package
v0.0.0-...-1bf7cb7 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package test provides test utilities

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckRequest

func CheckRequest(t *testing.T, expected, actual *http.Request)

CheckRequest compares two request, ignoring the User-Agent header.

func Flags

func Flags(t *testing.T, expected []string, cmd *cobra.Command)

Flags tests that the expected flags are defined.

func NewRequest

func NewRequest(t *testing.T, method, fullPath string, body io.Reader) *http.Request

NewRequest wraps httptest.NewRequest, and add reasonable default headers.

func Options

func Options(cmdFn func() *cobra.Command, optsFn func(context.Context, *pflag.FlagSet) (*kouch.Options, error)) func(*testing.T, OptionsTest)

Options returns an options-testing function for use with a testy.Table.

cmdFn must return a new, relevant, *cobra.Command optsFn is the Options function to be tested. It takes a context and flags.

func ValidateCmdTest

func ValidateCmdTest(args []string) func(*testing.T, CmdTest)

ValidateCmdTest validates a test. It is meant to be passed to testy's tests.Run() method.

Types

type CmdTest

type CmdTest struct {
	Args   []string
	Stdout string
	Stderr string
	Err    string
	Status int
}

CmdTest represents a single test for a complete kouch command.

type OptionsTest

type OptionsTest struct {
	Conf     *kouch.Config
	Args     []string
	Expected *kouch.Options
	Err      string
	Status   int
}

OptionsTest is a generic Options Test, reusable for any command

Jump to

Keyboard shortcuts

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