platformtest

package
v6.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package platformtest runs commands against a fake platform: an httptest server whose endpoints a test declares, which records every request it receives.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Home

func Home(t *testing.T) string

Home gives the test an empty home directory. Go reads USERPROFILE for it on Windows and HOME elsewhere, so both are set.

func Stderr added in v6.1.0

func Stderr(t *testing.T, fn func() error) (string, error)

Stderr captures what fn prints to standard error.

func Stdout

func Stdout(t *testing.T, fn func() error) (string, error)

Stdout captures what fn prints.

Types

type Platform

type Platform struct {
	Client *platform.Client
	URL    string
	// contains filtered or unexported fields
}

func New

func New(t *testing.T) *Platform

New starts a fake platform and points the CLI configuration at it.

func (*Platform) Handle

func (p *Platform) Handle(route string, reply func(Request) Reply)

Handle answers "METHOD /path"; a path segment written as * matches any value.

func (*Platform) Reply

func (p *Platform) Reply(route string, reply Reply)

Reply answers a route with a fixed reply.

func (*Platform) Requests

func (p *Platform) Requests(route string) []Request

type Reply

type Reply struct {
	Status  int
	JSON    any
	Body    string
	Headers map[string]string
}

type Request

type Request struct {
	Method string
	Path   string
	Query  map[string][]string
	Header http.Header
	Body   []byte
}

func (Request) JSON

func (r Request) JSON(t *testing.T) any

JSON decodes the request body.

Jump to

Keyboard shortcuts

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