testutil

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package testutil provides offline helpers for CLI tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPClient

func HTTPClient(fn RoundTripFunc) *http.Client

HTTPClient returns an HTTP client using fn as its transport.

func JSONResponse

func JSONResponse(req *http.Request, status int, body string) *http.Response

JSONResponse returns a minimal JSON HTTP response for fake transports.

Types

type CommandResult

type CommandResult struct {
	Stdout string
	Stderr string
	Err    error
}

CommandResult captures a CLI run.

func RunCommand

func RunCommand(cmd *cli.Command, args ...string) CommandResult

RunCommand runs a command with captured stdout and stderr.

type RoundTripFunc

type RoundTripFunc func(*http.Request) (*http.Response, error)

RoundTripFunc adapts a function into an http.RoundTripper.

func (RoundTripFunc) RoundTrip

func (f RoundTripFunc) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements http.RoundTripper.

Source Files

  • command.go
  • doc.go
  • http.go

Jump to

Keyboard shortcuts

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