testcli

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

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

func (*App) Close

func (a *App) Close() (err error)

Close cleans up resources exactly once

func (*App) Delete

func (a *App) Delete(path string, body io.Reader) (*Response, error)

func (*App) DeleteJSON

func (a *App) DeleteJSON(path string, body io.Reader) (*Response, error)

func (*App) Get

func (a *App) Get(path string) (*Response, error)

func (*App) GetJSON

func (a *App) GetJSON(path string) (*Response, error)

func (*App) Hot

func (a *App) Hot(path string) (*hot.Stream, error)

Hot connects to the event stream

func (*App) Patch

func (a *App) Patch(path string, body io.Reader) (*Response, error)

func (*App) PatchJSON

func (a *App) PatchJSON(path string, body io.Reader) (*Response, error)

func (*App) Post

func (a *App) Post(path string, body io.Reader) (*Response, error)

func (*App) PostJSON

func (a *App) PostJSON(path string, body io.Reader) (*Response, error)

func (*App) Request

func (a *App) Request(req *http.Request) (*Response, error)

func (*App) Wait

func (a *App) Wait() error

Wait for the app to finish. This isn't typically necessary

type Response

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

func (*Response) Body

func (r *Response) Body() *bytes.Buffer

func (*Response) Dump

func (r *Response) Dump() *bytes.Buffer

Diff the response the expected HTTP response

func (*Response) Header

func (r *Response) Header(key string) string

Header gets a value from a key

func (*Response) Headers

func (r *Response) Headers() *bytes.Buffer

func (*Response) Query

func (r *Response) Query(selector string) (*goquery.Selection, error)

Query a selector on the page using goquery

func (*Response) Status

func (r *Response) Status() int

Status returns the response status

type TestCLI

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

func New

func New(cli *cli.CLI) *TestCLI

func (*TestCLI) Env

func (c *TestCLI) Env(key, value string)

Env sets an environment variable, overriding any existing key.

func (*TestCLI) Run

func (c *TestCLI) Run(ctx context.Context, args ...string) (stdout, stderr *bytes.Buffer, err error)

Run the CLI with the provided args

func (*TestCLI) Start

func (c *TestCLI) Start(ctx context.Context, args ...string) (app *App, stdout *bytes.Buffer, stderr *bytes.Buffer, err error)

func (*TestCLI) Stdin

func (c *TestCLI) Stdin(stdin io.Reader)

Stdin adds a reader as standard input.

Jump to

Keyboard shortcuts

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