texsting

package
Version: v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2021 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package texsting supports the use of texst in your Go tests.

Example reads reference text from TestError.texst:

func TestError(t *testing.T) {
	resp, _ := http.Get("https://httpbin.org/get")
	defer resp.Body.Close()
	Error(t, "", resp.Body)
}

Reference Text:

> {
>   "args": {},
>   "headers": {
>     "Accept-Encoding": "gzip",
>     "Host": "httpbin.org",
>     "User-Agent": "Go-http-client/2.0",
 *                   aaaaaaaaaaaaaaaaaa
>     "X-Amzn-Trace-Id": "Root=1-602f798d-1c84bdc472ff9a2d3ec50f3b"
 =                             u uuuuuuuu uuuuuuuuuuuuuuuuuuuuuuuu
>   },
>   "origin": "10.0.0.1",
 +             aa a a a
>   "url": "https://httpbin.org/get"
> }

Index

Constants

View Source
const (
	StdSuffix = ".texst"
	NoSuffix  = "\x00"
)

Variables

This section is empty.

Functions

func Error added in v0.4.0

func Error(t *testing.T, hint string, subj io.Reader) error

func Fatal added in v0.4.0

func Fatal(t *testing.T, hint string, subj io.Reader)

func MismatchError added in v0.4.2

func MismatchError(t *testing.T, hint string, abort bool) texst.MismatchFunc

func Record added in v0.4.0

func Record(t *testing.T, hint string, subj io.Reader)

Types

type Config added in v0.4.0

type Config struct {
	RefFileName     func(t *testing.T, hint string) string
	MismatchLimit   int
	RecordOverwrite bool
}

func (Config) Error added in v0.4.0

func (cfg Config) Error(t *testing.T, hint string, subj io.Reader) error

func (Config) Fatal added in v0.4.0

func (cfg Config) Fatal(t *testing.T, hint string, subj io.Reader)

func (Config) Record added in v0.4.0

func (cfg Config) Record(t *testing.T, hint string, subj io.Reader)

type RefRepo

type RefRepo struct {
	Dir    string
	Suffix string
}

func (RefRepo) Filename added in v0.4.0

func (rr RefRepo) Filename(t *testing.T, hint string) string

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL