assert

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package assert provides value assertions.

Index

Constants

This section is empty.

Variables

View Source
var AppendError = multierror.Append

AppendError is a helper function that will append more errors onto an Error in order to create a larger multi-error.

Functions

func And added in v0.5.1

func And(assertions ...Assertion) func(*query.Query) Assertion

And returns a new assertion to ensure that value passes all assertions. If the assertions are empty, it returns an error.

func Contains

func Contains(assertion Assertion) func(*query.Query) Assertion

Contains returns an assertion to ensure a value contains the value.

func NotContains

func NotContains(assertion Assertion) func(*query.Query) Assertion

NotContains returns an assertion to ensure a value doesn't contain the value.

func Or added in v0.5.0

func Or(assertions ...Assertion) func(*query.Query) Assertion

Or returns new assertion to ensure that value passes at least one of assertions. If the assertions are empty, it returns an error.

func Regexp added in v0.6.0

func Regexp(expr string) func(*query.Query) Assertion

Regexp returns an assertion to ensure a value matches the regular expression pattern.

Types

type Assertion

type Assertion interface {
	Assert(v interface{}) error
}

Assertion implements value assertion.

func Build

func Build(expect interface{}) Assertion

Build creates an assertion from Go value.

func Equal

func Equal(q *query.Query, expected interface{}) Assertion

Equal returns an assertion to ensure a value equals the expected value.

func NotZero

func NotZero(q *query.Query) Assertion

NotZero returns an assertion to ensure a value is not zero value.

type AssertionFunc

type AssertionFunc func(v interface{}) error

AssertionFunc is an adaptor to allow the use of ordinary functions as assertions.

func (AssertionFunc) Assert

func (f AssertionFunc) Assert(v interface{}) error

Assert asserts the v.

type Error

type Error = multierror.Error

Error is an error type to track multiple errors.

Jump to

Keyboard shortcuts

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