Search and commands

↑ ↓ to select · Enter to open · Esc to close

Type to search packages.

checkers

v0.0.0-20140813210533-fa988ea027e2
github.com/kapilt/testing/checkers

Documentation

pkg.go.dev ↗

Table of contents

↓ to select · Enter to jump· Shift+Enter for source

26 matches

Top ↑

Variables

Contains

var Contains gc.Checker = &containsChecker{
	&gc.CheckerInfo{Name: "Contains", Params: []string{"obtained", "expected"}},
}

DeepEquals

var DeepEquals gc.Checker = &deepEqualsChecker{
	&gc.CheckerInfo{Name: "DeepEquals", Params: []string{"obtained", "expected"}},
}

The DeepEquals checker verifies that the obtained value is deep-equal to the expected value. The check will work correctly even when facing slices, interfaces, and values of different types (which always fail the test).

For example:

c.Assert(value, DeepEquals, 42)
c.Assert(array, DeepEquals, []string{"hi", "there"})

This checker differs from gocheck.DeepEquals in that it will compare a nil slice equal to an empty slice, and a nil map equal to an empty map.

DoesNotExist

var DoesNotExist gc.Checker = &doesNotExistChecker{
	&gc.CheckerInfo{Name: "DoesNotExist", Params: []string{"obtained"}},
}

DurationLessThan

var DurationLessThan gc.Checker = &durationLessThanChecker{
	&gc.CheckerInfo{Name: "DurationLessThan", Params: []string{"obtained", "expected"}},
}

GreaterThan

var GreaterThan gc.Checker = &greaterThanChecker{
	&gc.CheckerInfo{Name: "GreaterThan", Params: []string{"obtained", "expected"}},
}

HasPrefix

var HasPrefix gc.Checker = &hasPrefixChecker{
	&gc.CheckerInfo{Name: "HasPrefix", Params: []string{"obtained", "expected"}},
}

HasSuffix

var HasSuffix gc.Checker = &hasSuffixChecker{
	&gc.CheckerInfo{Name: "HasSuffix", Params: []string{"obtained", "expected"}},
}

IsDirectory

var IsDirectory gc.Checker = &isDirectoryChecker{
	&gc.CheckerInfo{Name: "IsDirectory", Params: []string{"obtained"}},
}

IsFalse

var IsFalse gc.Checker = gc.Not(IsTrue)

IsTrue checks whether a value has an underlying boolean type and is false.

IsNonEmptyFile

var IsNonEmptyFile gc.Checker = &isNonEmptyFileChecker{
	&gc.CheckerInfo{Name: "IsNonEmptyFile", Params: []string{"obtained"}},
}
var IsSymlink gc.Checker = &isSymlinkChecker{
	&gc.CheckerInfo{Name: "IsSymlink", Params: []string{"obtained"}},
}

IsTrue

var IsTrue gc.Checker = &isTrueChecker{
	&gc.CheckerInfo{Name: "IsTrue", Params: []string{"obtained"}},
}

IsTrue checks whether a value has an underlying boolean type and is true.

LessThan

var LessThan gc.Checker = &lessThanChecker{
	&gc.CheckerInfo{Name: "LessThan", Params: []string{"obtained", "expected"}},
}

LogMatches

var LogMatches gc.Checker = &logMatches{
	&gc.CheckerInfo{Name: "LogMatches", Params: []string{"obtained", "expected"}},
}

LogMatches checks whether a given TestLogValues actually contains the log messages we expected. If you compare it against a list of strings, we only compare that the strings in the messages are correct. You can alternatively pass a slice of SimpleMessage and we will check that the log levels are also correct.

The log may contain additional messages before and after each of the specified expected messages.

SameContents

var SameContents gc.Checker = &sameContents{
	&gc.CheckerInfo{Name: "SameContents", Params: []string{"obtained", "expected"}},
}

SameContents checks that the obtained slice contains all the values (and same number of values) of the expected slice and vice versa, without respect to order or duplicates. Uses DeepEquals on mapped contents to compare.

Satisfies

var Satisfies gc.Checker = &satisfiesChecker{
	&gc.CheckerInfo{
		Name:   "Satisfies",
		Params: []string{"obtained", "func(T) bool"},
	},
}

Satisfies checks whether a value causes the argument function to return true. The function must be of type func(T) bool where the value being checked is assignable to T.

SymlinkDoesNotExist

var SymlinkDoesNotExist gc.Checker = &symlinkDoesNotExistChecker{
	&gc.CheckerInfo{Name: "SymlinkDoesNotExist", Params: []string{"obtained"}},
}

Functions

DeepEqual

func DeepEqual(a1, a2 interface{}) (bool, error)

DeepEqual tests for deep equality. It uses normal == equality where possible but will scan elements of arrays, slices, maps, and fields of structs. In maps, keys are compared with == but elements use deep equality. DeepEqual correctly handles recursive types. Functions are equal only if they are both nil.

DeepEqual differs from reflect.DeepEqual in that an empty slice is equal to a nil slice. If the two values compare unequal, the resulting error holds the first difference encountered.

TimeBetween

func TimeBetween(start, end time.Time) gc.Checker

Types

SimpleMessage

type SimpleMessage struct {
	Level   loggo.Level
	Message string
}

SimpleMessage.String

func (s SimpleMessage) String() string

SimpleMessages

type SimpleMessages []SimpleMessage

SimpleMessages.GoString

func (s SimpleMessages) GoString() string

Dependency graph