got

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2020 License: MIT Imports: 7 Imported by: 8

README

Overview

A tiny test framework for go projects. The test of this lib is its doc.

All functions in this lib are side-effect free.

Examples

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Each added in v0.0.3

func Each(t Testable, iteratee interface{}) (count int)

Each runs each exported method Fn on type Ctx as a subtest of t. The iteratee can be a struct Ctx or:

iteratee(t Testable) (ctx Ctx)

Each Fn will be called like:

ctx.Fn()

If iteratee is Ctx, its Assertion and T fields will be set to New(t) and t for each test. Any Fn that has the same name with the embedded one will be ignored.

Types

type Assertion added in v0.0.3

type Assertion struct {
	Testable
	// contains filtered or unexported fields
}

Assertion is the assertion context

func New added in v0.0.3

func New(t Testable) Assertion

New assertion helper

func NewWith added in v0.1.0

func NewWith(t Testable, opts Options) Assertion

NewWith assertion helper with options

func (Assertion) E added in v0.0.6

func (as Assertion) E(args ...interface{})

E is a shortcut for Nil(args...).Must()

func (Assertion) Eq added in v0.0.3

func (as Assertion) Eq(a, b interface{}) (result Result)

Eq a == b

func (Assertion) Err added in v0.0.3

func (as Assertion) Err(args ...interface{}) (result Result)

Err args[-1] is error and not nil

func (Assertion) False added in v0.0.3

func (as Assertion) False(a bool) (result Result)

False a == false

func (Assertion) Gt added in v0.0.3

func (as Assertion) Gt(a, b interface{}) (result Result)

Gt a > b

func (Assertion) Gte added in v0.0.3

func (as Assertion) Gte(a, b interface{}) (result Result)

Gte a >= b

func (Assertion) Has added in v0.0.3

func (as Assertion) Has(container, str string) (result Result)

Has str in container

func (Assertion) Is added in v0.0.3

func (as Assertion) Is(a, b interface{}) (result Result)

Is a a kind of b

func (Assertion) Len added in v0.0.3

func (as Assertion) Len(list interface{}, l int) (result Result)

Len len(list) == l

func (Assertion) Lt added in v0.0.3

func (as Assertion) Lt(a, b interface{}) (result Result)

Lt a < b

func (Assertion) Lte added in v0.0.3

func (as Assertion) Lte(a, b interface{}) (result Result)

Lte a <= b

func (Assertion) Neq added in v0.0.3

func (as Assertion) Neq(a, b interface{}) (result Result)

Neq a != b

func (Assertion) Nil added in v0.0.3

func (as Assertion) Nil(args ...interface{}) (result Result)

Nil args[-1] == nil

func (Assertion) NotNil added in v0.0.3

func (as Assertion) NotNil(args ...interface{}) (result Result)

NotNil args[-1] != nil

func (Assertion) Panic added in v0.0.3

func (as Assertion) Panic(fn func()) (result Result)

Panic fn should panic

func (Assertion) Regex added in v0.0.3

func (as Assertion) Regex(pattern, str string) (result Result)

Regex matches str

func (Assertion) True added in v0.0.3

func (as Assertion) True(a bool) (result Result)

True a == true

type Options added in v0.1.0

type Options struct {
	// Dump a value to human readable string
	Dump func(interface{}) string

	// Format keywords in the assertion message.
	// Such as color it for CLI output.
	Keyword func(string) string
}

Options for Assertion

func Defaults added in v0.1.0

func Defaults() Options

Defaults for Options

type Result added in v0.1.0

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

Result helper

func (Result) Msg added in v0.1.0

func (r Result) Msg(format string, args ...interface{}) Result

Msg if fails

func (Result) Must added in v0.1.0

func (r Result) Must() Result

Must FailNow if fails

type Testable added in v0.0.3

type Testable interface {
	Helper()
	Fail()
	FailNow()
	Logf(format string, args ...interface{})
}

Testable interface

Directories

Path Synopsis
lib
benchmark Module
example Module

Jump to

Keyboard shortcuts

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