assertjson

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package assertjson provides methods for testing JSON values. Selecting JSON values provided by JSON Pointer Syntax (https://tools.ietf.org/html/rfc6901).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileHas

func FileHas(t TestingT, filename string, jsonAssert JSONAssertFunc)

FileHas loads JSON from file and runs user callback for testing its nodes.

func Has

func Has(t TestingT, data []byte, jsonAssert JSONAssertFunc)

Has - loads JSON from byte slice and runs user callback for testing its nodes.

Types

type ArrayAssertion added in v0.4.0

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

ArrayAssertion is used to build a chain of assertions for the array node.

func (*ArrayAssertion) Length added in v0.4.0

func (a *ArrayAssertion) Length() int

Length returns array underlying array length.

func (*ArrayAssertion) WithLength added in v0.4.0

func (a *ArrayAssertion) WithLength(expected int, msgAndArgs ...interface{}) *ArrayAssertion

WithLength asserts that the JSON node is an array with length equal to the given value.

func (*ArrayAssertion) WithLengthGreaterThan added in v0.4.0

func (a *ArrayAssertion) WithLengthGreaterThan(expected int, msgAndArgs ...interface{}) *ArrayAssertion

WithLengthGreaterThan asserts that the JSON node is an array with length greater than the value.

func (*ArrayAssertion) WithLengthGreaterThanOrEqual added in v0.4.0

func (a *ArrayAssertion) WithLengthGreaterThanOrEqual(expected int, msgAndArgs ...interface{}) *ArrayAssertion

WithLengthGreaterThanOrEqual asserts that the JSON node is an array with length greater than or equal to the value.

func (*ArrayAssertion) WithLengthLessThan added in v0.4.0

func (a *ArrayAssertion) WithLengthLessThan(expected int, msgAndArgs ...interface{}) *ArrayAssertion

WithLengthLessThan asserts that the JSON node is an array with length less than the value.

func (*ArrayAssertion) WithLengthLessThanOrEqual added in v0.4.0

func (a *ArrayAssertion) WithLengthLessThanOrEqual(expected int, msgAndArgs ...interface{}) *ArrayAssertion

WithLengthLessThanOrEqual asserts that the JSON node is an array with length less than or equal to the value.

func (*ArrayAssertion) WithUniqueElements added in v0.4.0

func (a *ArrayAssertion) WithUniqueElements(msgAndArgs ...interface{}) *ArrayAssertion

WithUniqueElements asserts that the JSON node is an array with unique elements.

type AssertJSON

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

AssertJSON - main structure that holds parsed JSON.

func (*AssertJSON) At added in v0.3.0

func (j *AssertJSON) At(path string) *AssertJSON

At is used to test assertions on some node in a batch. It returns AssertJSON object on that node.

func (*AssertJSON) Atf added in v0.3.0

func (j *AssertJSON) Atf(format string, a ...interface{}) *AssertJSON

Atf is used to test assertions on some node in a batch. It returns AssertJSON object on that node. It calculates path by applying fmt.Sprintf function.

func (*AssertJSON) Node

func (j *AssertJSON) Node(path string) *AssertNode

Node searches for JSON node by JSON Path Syntax. Returns struct for asserting the node values.

func (*AssertJSON) Nodef added in v0.3.0

func (j *AssertJSON) Nodef(format string, a ...interface{}) *AssertNode

Nodef searches for JSON node by JSON Path Syntax. Returns struct for asserting the node values. It calculates path by applying fmt.Sprintf function.

type AssertNode

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

AssertNode - structure for asserting JSON node.

func (*AssertNode) ArrayLength added in v0.4.0

func (node *AssertNode) ArrayLength() int

ArrayLength asserts that JSON node is array and return its length. It is an alias for IsArray().Length().

func (*AssertNode) AssertString added in v0.2.1

func (node *AssertNode) AssertString(assertFunc func(t testing.TB, value string))

AssertString asserts that the JSON node has a string value and it is satisfied by the user function assertFunc. Deprecated: use IsString().Assert() instead.

func (*AssertNode) Contains

func (node *AssertNode) Contains(contain string, msgAndArgs ...interface{})

Contains asserts that the JSON node has a string value that contains a string.

func (*AssertNode) DoesNotContain

func (node *AssertNode) DoesNotContain(contain string, msgAndArgs ...interface{})

DoesNotContain asserts that the JSON node has a string value that does not contain a string.

func (*AssertNode) DoesNotExist

func (node *AssertNode) DoesNotExist(msgAndArgs ...interface{})

DoesNotExist asserts that the JSON node does not exist.

func (*AssertNode) DoesNotMatch

func (node *AssertNode) DoesNotMatch(regexp interface{}, msgAndArgs ...interface{})

DoesNotMatch asserts that the JSON node has a string value that does not match the regular expression.

func (*AssertNode) EqualJSON added in v0.4.0

func (node *AssertNode) EqualJSON(expected string, msgAndArgs ...interface{})

EqualJSON asserts that node is equal to JSON string.

func (*AssertNode) EqualToTheFloat

func (node *AssertNode) EqualToTheFloat(expectedValue float64, msgAndArgs ...interface{})

EqualToTheFloat asserts that the JSON node has a float value equals to the given value. Deprecated: use IsNumber() instead.

func (*AssertNode) EqualToTheInteger

func (node *AssertNode) EqualToTheInteger(expectedValue int, msgAndArgs ...interface{})

EqualToTheInteger asserts that the JSON node has an integer value equals to the given value. Deprecated: use IsInteger() instead.

func (*AssertNode) EqualToTheString

func (node *AssertNode) EqualToTheString(expectedValue string, msgAndArgs ...interface{})

EqualToTheString asserts that the JSON node has a string value equals to the given value. Deprecated: use IsString().EqualTo() instead.

func (*AssertNode) Exists

func (node *AssertNode) Exists(msgAndArgs ...interface{}) bool

Exists asserts that the JSON node exists. Returns true if node exists.

func (*AssertNode) Float added in v0.4.0

func (node *AssertNode) Float() float64

Float returns the JSON node value as a 64-bit float. If node does not exist it returns a zero. If node value is not numeric, it logs the error and returns a zero value.

func (*AssertNode) ForEach added in v0.4.0

func (node *AssertNode) ForEach(assertNode func(node *AssertNode))

ForEach executes callback function for node assertion on each array or object node.

func (*AssertNode) Integer added in v0.4.0

func (node *AssertNode) Integer() int

Integer returns the JSON node value as an integer. If node does not exist it returns a zero. If node value is not an integer, it logs the error and returns a zero value.

func (*AssertNode) IsArray added in v0.4.0

func (node *AssertNode) IsArray(msgAndArgs ...interface{}) *ArrayAssertion

IsArray asserts that the JSON node is an array. It returns ArrayAssertion to execute a chain of assertions for the node value.

func (*AssertNode) IsArrayWithElementsCount

func (node *AssertNode) IsArrayWithElementsCount(count int, msgAndArgs ...interface{})

IsArrayWithElementsCount asserts that the JSON node is an array with given elements count. Deprecated: use IsArray().WithLength() instead.

func (*AssertNode) IsEmail added in v0.4.0

func (node *AssertNode) IsEmail(msgAndArgs ...interface{})

IsEmail asserts that the JSON node has a string value with email. Validation is based on simplified pattern. It allows all values with an "@" symbol in, and a "." in the second host part of the email address.

func (*AssertNode) IsFalse

func (node *AssertNode) IsFalse(msgAndArgs ...interface{})

IsFalse asserts that the JSON node equals to the boolean with `false` value.

func (*AssertNode) IsFloat

func (node *AssertNode) IsFloat(msgAndArgs ...interface{}) *NumberAssertion

IsFloat asserts that the JSON node has a float value. It returns NumberAssertion to execute a chain of assertions for the node value.

func (*AssertNode) IsHTML5Email added in v0.4.0

func (node *AssertNode) IsHTML5Email(msgAndArgs ...interface{})

IsHTML5Email asserts that the JSON node has a string value with email. Validation is based on pattern for HTML5 (see https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address).

func (*AssertNode) IsInteger

func (node *AssertNode) IsInteger(msgAndArgs ...interface{}) *IntegerAssertion

IsInteger asserts that the JSON node has an integer value. It returns IntegerAssertion to execute a chain of assertions for the node value.

func (*AssertNode) IsNotNull

func (node *AssertNode) IsNotNull(msgAndArgs ...interface{})

IsNotNull asserts that the JSON node not equals to `null` value.

func (*AssertNode) IsNull

func (node *AssertNode) IsNull(msgAndArgs ...interface{})

IsNull asserts that the JSON node equals to `null` value.

func (*AssertNode) IsNumber added in v0.4.0

func (node *AssertNode) IsNumber(msgAndArgs ...interface{}) *NumberAssertion

IsNumber asserts that the JSON node has a float value. It returns NumberAssertion to execute a chain of assertions for the node value.

func (*AssertNode) IsNumberGreaterThan

func (node *AssertNode) IsNumberGreaterThan(value float64, msgAndArgs ...interface{})

IsNumberGreaterThan asserts that the JSON node has a number greater than the given value. Deprecated: use IsNumber().GreaterThan() instead.

func (*AssertNode) IsNumberGreaterThanOrEqual

func (node *AssertNode) IsNumberGreaterThanOrEqual(value float64, msgAndArgs ...interface{})

IsNumberGreaterThanOrEqual asserts that the JSON node has a number greater than or equal to the given value. Deprecated: use IsNumber().GreaterThanOrEqual() instead.

func (*AssertNode) IsNumberInRange

func (node *AssertNode) IsNumberInRange(min, max float64, msgAndArgs ...interface{})

IsNumberInRange asserts that the JSON node has a number with value in the given range. Deprecated: use IsNumber().GreaterThanOrEqual().LessThanOrEqual() instead.

func (*AssertNode) IsNumberLessThan

func (node *AssertNode) IsNumberLessThan(value float64, msgAndArgs ...interface{})

IsNumberLessThan asserts that the JSON node has a number less than the given value. Deprecated: use IsNumber().LessThan() instead.

func (*AssertNode) IsNumberLessThanOrEqual

func (node *AssertNode) IsNumberLessThanOrEqual(value float64, msgAndArgs ...interface{})

IsNumberLessThanOrEqual asserts that the JSON node has a number less than or equal to the given value. Deprecated: use IsNumber().LessThanOrEqual() instead.

func (*AssertNode) IsObject added in v0.4.0

func (node *AssertNode) IsObject(msgAndArgs ...interface{}) *ObjectAssertion

IsObject asserts that the JSON node is an object. It returns ObjectAssertion to execute a chain of assertions for the node value.

func (*AssertNode) IsObjectWithPropertiesCount

func (node *AssertNode) IsObjectWithPropertiesCount(count int, msgAndArgs ...interface{})

IsObjectWithPropertiesCount asserts that the JSON node is an object with given properties count. Deprecated: use IsObject().WithPropertiesCount() instead.

func (*AssertNode) IsString

func (node *AssertNode) IsString(msgAndArgs ...interface{}) *StringAssertion

IsString asserts that the JSON node has a string value. It returns StringAssertion to execute a chain of assertions for the node value.

func (*AssertNode) IsStringWithLength

func (node *AssertNode) IsStringWithLength(length int, msgAndArgs ...interface{})

IsStringWithLength asserts that the JSON node has a string value with length equal to the given value. Deprecated: use IsString().WithLength() instead.

func (*AssertNode) IsStringWithLengthInRange

func (node *AssertNode) IsStringWithLengthInRange(min int, max int, msgAndArgs ...interface{})

IsStringWithLengthInRange asserts that the JSON node has a string value with length in a given range. Deprecated: use IsString().WithLengthGreaterThanOrEqual().WithLengthLessThanOrEqual() instead.

func (*AssertNode) IsTrue

func (node *AssertNode) IsTrue(msgAndArgs ...interface{})

IsTrue asserts that the JSON node equals to the boolean with `true` value.

func (*AssertNode) IsURL added in v0.4.0

func (node *AssertNode) IsURL(msgAndArgs ...interface{}) *URLAssertion

IsURL asserts that the JSON node has a string value with URL.

func (*AssertNode) IsUUID added in v0.4.0

func (node *AssertNode) IsUUID(msgAndArgs ...interface{}) *UUIDAssertion

IsUUID asserts that the JSON node has a string value with UUID.

func (*AssertNode) JSON added in v0.4.0

func (node *AssertNode) JSON() []byte

JSON returns the JSON node value as a marshaled JSON.

func (*AssertNode) Matches

func (node *AssertNode) Matches(regexp interface{}, msgAndArgs ...interface{})

Matches asserts that the JSON node has a string value that matches the regular expression.

func (*AssertNode) ObjectPropertiesCount added in v0.4.0

func (node *AssertNode) ObjectPropertiesCount() int

ObjectPropertiesCount asserts that JSON node is an object and return its properties count. It is an alias for IsObject().PropertiesCount().

func (*AssertNode) Path added in v0.4.0

func (node *AssertNode) Path() string

Path returns current node path as string.

func (*AssertNode) String added in v0.4.0

func (node *AssertNode) String() string

String returns the JSON node value as a string. If node does not exist it returns an empty string. If the node value is an integer it returns a formatted integer. If the node value is a float it returns a formatted float. Otherwise, it logs the error and returns an empty string.

func (*AssertNode) UUID added in v0.4.0

func (node *AssertNode) UUID() uuid.UUID

UUID asserts that the JSON node is UUID and returns its value. If value is not a valid UUID, then it will return nil UUID. It is an alias for IsUUID().Value().

func (*AssertNode) Value added in v0.4.0

func (node *AssertNode) Value() interface{}

Value returns JSON node value as an interface. If node does not exist it returns nil.

type IntegerAssertion added in v0.4.0

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

IntegerAssertion is used to build a chain of assertions for the integer node.

func (*IntegerAssertion) EqualTo added in v0.4.0

func (a *IntegerAssertion) EqualTo(expected int, msgAndArgs ...interface{}) *IntegerAssertion

EqualTo asserts that the JSON node has an integer value equals to the given value.

func (*IntegerAssertion) GreaterThan added in v0.4.0

func (a *IntegerAssertion) GreaterThan(expected int, msgAndArgs ...interface{}) *IntegerAssertion

GreaterThan asserts that the JSON node has an integer value greater than the given value.

func (*IntegerAssertion) GreaterThanOrEqual added in v0.4.0

func (a *IntegerAssertion) GreaterThanOrEqual(expected int, msgAndArgs ...interface{}) *IntegerAssertion

GreaterThanOrEqual asserts that the JSON node has an integer value greater than or equal to the given value.

func (*IntegerAssertion) LessThan added in v0.4.0

func (a *IntegerAssertion) LessThan(expected int, msgAndArgs ...interface{}) *IntegerAssertion

LessThan asserts that the JSON node has an integer value less than the given value.

func (*IntegerAssertion) LessThanOrEqual added in v0.4.0

func (a *IntegerAssertion) LessThanOrEqual(expected int, msgAndArgs ...interface{}) *IntegerAssertion

LessThanOrEqual asserts that the JSON node has an integer value less than or equal to the given value.

type JSONAssertFunc

type JSONAssertFunc func(json *AssertJSON)

JSONAssertFunc - callback function used for asserting JSON nodes.

type NumberAssertion added in v0.4.0

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

NumberAssertion is used to build a chain of assertions for the numeric node.

func (*NumberAssertion) EqualTo added in v0.4.0

func (a *NumberAssertion) EqualTo(expected float64, msgAndArgs ...interface{}) *NumberAssertion

EqualTo asserts that the JSON node has a numeric value equals to the given value.

func (*NumberAssertion) EqualToWithDelta added in v0.4.0

func (a *NumberAssertion) EqualToWithDelta(expected, delta float64, msgAndArgs ...interface{}) *NumberAssertion

EqualToWithDelta asserts that the JSON node has a numeric value equals to the given value with delta.

func (*NumberAssertion) GreaterThan added in v0.4.0

func (a *NumberAssertion) GreaterThan(expected float64, msgAndArgs ...interface{}) *NumberAssertion

GreaterThan asserts that the JSON node has a numeric value greater than the given value.

func (*NumberAssertion) GreaterThanOrEqual added in v0.4.0

func (a *NumberAssertion) GreaterThanOrEqual(expected float64, msgAndArgs ...interface{}) *NumberAssertion

GreaterThanOrEqual asserts that the JSON node has a numeric value greater than or equal to the given value.

func (*NumberAssertion) LessThan added in v0.4.0

func (a *NumberAssertion) LessThan(expected float64, msgAndArgs ...interface{}) *NumberAssertion

LessThan asserts that the JSON node has a numeric value less than the given value.

func (*NumberAssertion) LessThanOrEqual added in v0.4.0

func (a *NumberAssertion) LessThanOrEqual(expected float64, msgAndArgs ...interface{}) *NumberAssertion

LessThanOrEqual asserts that the JSON node has a numeric value less than or equal to the given value.

type ObjectAssertion added in v0.4.0

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

ObjectAssertion is used to build a chain of assertions for the object node.

func (*ObjectAssertion) PropertiesCount added in v0.4.0

func (a *ObjectAssertion) PropertiesCount() int

PropertiesCount returns array underlying object properties count.

func (*ObjectAssertion) WithPropertiesCount added in v0.4.0

func (a *ObjectAssertion) WithPropertiesCount(expected int, msgAndArgs ...interface{}) *ObjectAssertion

WithPropertiesCount asserts that the JSON node is an object with properties count equal to the given value.

func (*ObjectAssertion) WithPropertiesCountGreaterThan added in v0.4.0

func (a *ObjectAssertion) WithPropertiesCountGreaterThan(expected int, msgAndArgs ...interface{}) *ObjectAssertion

WithPropertiesCountGreaterThan asserts that the JSON node is an object with properties count greater than the value.

func (*ObjectAssertion) WithPropertiesCountGreaterThanOrEqual added in v0.4.0

func (a *ObjectAssertion) WithPropertiesCountGreaterThanOrEqual(expected int, msgAndArgs ...interface{}) *ObjectAssertion

WithPropertiesCountGreaterThanOrEqual asserts that the JSON node is an object with propertiesCount greater than or equal to the value.

func (*ObjectAssertion) WithPropertiesCountLessThan added in v0.4.0

func (a *ObjectAssertion) WithPropertiesCountLessThan(expected int, msgAndArgs ...interface{}) *ObjectAssertion

WithPropertiesCountLessThan asserts that the JSON node is an object with properties count less than the value.

func (*ObjectAssertion) WithPropertiesCountLessThanOrEqual added in v0.4.0

func (a *ObjectAssertion) WithPropertiesCountLessThanOrEqual(expected int, msgAndArgs ...interface{}) *ObjectAssertion

WithPropertiesCountLessThanOrEqual asserts that the JSON node is an object with properties count less than or equal to the value.

func (*ObjectAssertion) WithUniqueElements added in v0.4.0

func (a *ObjectAssertion) WithUniqueElements(msgAndArgs ...interface{}) *ObjectAssertion

WithUniqueElements asserts that the JSON node is an object with unique elements.

type StringAssertion added in v0.4.0

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

StringAssertion is used to build a chain of assertions for the string node.

func (*StringAssertion) Assert added in v0.4.0

func (a *StringAssertion) Assert(assertFunc func(t testing.TB, value string)) *StringAssertion

Assert asserts that the string node has that is satisfied by the user function assertFunc.

func (*StringAssertion) Contains added in v0.4.0

func (a *StringAssertion) Contains(value string, msgAndArgs ...interface{}) *StringAssertion

Contains asserts that the JSON node has a string value that contains a string.

func (*StringAssertion) EqualTo added in v0.4.0

func (a *StringAssertion) EqualTo(expectedValue string, msgAndArgs ...interface{}) *StringAssertion

EqualTo asserts that the JSON node has a string value equals to the given value.

func (*StringAssertion) IsEmail added in v0.4.0

func (a *StringAssertion) IsEmail(msgAndArgs ...interface{}) *StringAssertion

IsEmail asserts that the JSON node has a string value with email. Validation is based on simplified pattern. It allows all values with an "@" symbol in, and a "." in the second host part of the email address.

func (*StringAssertion) IsHTML5Email added in v0.4.0

func (a *StringAssertion) IsHTML5Email(msgAndArgs ...interface{}) *StringAssertion

IsHTML5Email asserts that the JSON node has a string value with email. Validation is based on pattern for HTML5 (see https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address).

func (*StringAssertion) IsURL added in v0.4.0

func (a *StringAssertion) IsURL(msgAndArgs ...interface{}) *URLAssertion

IsURL asserts that the JSON node has a string value with URL.

func (*StringAssertion) Matches added in v0.4.0

func (a *StringAssertion) Matches(regexp interface{}, msgAndArgs ...interface{}) *StringAssertion

Matches asserts that the JSON node has a string value that matches the regular expression.

func (*StringAssertion) NotContains added in v0.4.0

func (a *StringAssertion) NotContains(value string, msgAndArgs ...interface{}) *StringAssertion

NotContains asserts that the JSON node has a string value that does not contain a string.

func (*StringAssertion) NotMatches added in v0.4.0

func (a *StringAssertion) NotMatches(regexp interface{}, msgAndArgs ...interface{}) *StringAssertion

NotMatches asserts that the JSON node has a string value that does not match the regular expression.

func (*StringAssertion) That added in v0.4.0

func (a *StringAssertion) That(f func(s string) error, msgAndArgs ...interface{}) *StringAssertion

That asserts that the JSON node has a string value that is satisfied by callback function.

func (*StringAssertion) WithLength added in v0.4.0

func (a *StringAssertion) WithLength(length int, msgAndArgs ...interface{}) *StringAssertion

WithLength asserts that the JSON node has a string value with length equal to the given value.

func (*StringAssertion) WithLengthGreaterThan added in v0.4.0

func (a *StringAssertion) WithLengthGreaterThan(expected int, msgAndArgs ...interface{}) *StringAssertion

WithLengthGreaterThan asserts that the JSON node has a string value with length greater than the value.

func (*StringAssertion) WithLengthGreaterThanOrEqual added in v0.4.0

func (a *StringAssertion) WithLengthGreaterThanOrEqual(expected int, msgAndArgs ...interface{}) *StringAssertion

WithLengthGreaterThanOrEqual asserts that the JSON node has a string value with length greater than or equal to the value.

func (*StringAssertion) WithLengthLessThan added in v0.4.0

func (a *StringAssertion) WithLengthLessThan(expected int, msgAndArgs ...interface{}) *StringAssertion

WithLengthLessThan asserts that the JSON node has a string value with length less than the value.

func (*StringAssertion) WithLengthLessThanOrEqual added in v0.4.0

func (a *StringAssertion) WithLengthLessThanOrEqual(expected int, msgAndArgs ...interface{}) *StringAssertion

WithLengthLessThanOrEqual asserts that the JSON node has a string value with length less than or equal to the value.

func (*StringAssertion) WithUUID added in v0.4.0

func (a *StringAssertion) WithUUID(msgAndArgs ...interface{}) *UUIDAssertion

WithUUID asserts that the JSON node has a string value with UUID.

type TestingT added in v0.4.0

type TestingT interface {
	Helper()
	Errorf(format string, args ...interface{})
}

TestingT is an interface wrapper around *testing.T.

type URLAssertion added in v0.4.0

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

URLAssertion is used to build a chain of assertions for the URL node.

func (*URLAssertion) That added in v0.4.0

func (a *URLAssertion) That(f func(u *url.URL) error, msgAndArgs ...interface{}) *URLAssertion

That asserts that the JSON node has a URL value that is satisfied by callback function.

func (*URLAssertion) WithHosts added in v0.4.0

func (a *URLAssertion) WithHosts(hosts ...string) *URLAssertion

WithHosts additionally asserts than URL host contains one of the given values.

func (*URLAssertion) WithSchemas added in v0.4.0

func (a *URLAssertion) WithSchemas(schemas ...string) *URLAssertion

WithSchemas additionally asserts than URL schema contains one of the given values.

type UUIDAssertion added in v0.4.0

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

UUIDAssertion is used to build a chain of assertions for the UUID node.

func (*UUIDAssertion) EqualTo added in v0.4.0

func (a *UUIDAssertion) EqualTo(expected uuid.UUID, msgAndArgs ...interface{}) *UUIDAssertion

EqualTo asserts that the JSON node is UUID equals to the given value.

func (*UUIDAssertion) Nil added in v0.4.0

func (a *UUIDAssertion) Nil(msgAndArgs ...interface{}) *UUIDAssertion

Nil asserts that the JSON node has a string value equals to nil UUID.

func (*UUIDAssertion) NotNil added in v0.4.0

func (a *UUIDAssertion) NotNil(msgAndArgs ...interface{}) *UUIDAssertion

NotNil asserts that the JSON node has a string value equals to not nil UUID.

func (*UUIDAssertion) Value added in v0.4.0

func (a *UUIDAssertion) Value() uuid.UUID

Value returns JSON node value as UUID. If string is not a valid UUID it returns nil UUID.

func (*UUIDAssertion) Variant added in v0.4.0

func (a *UUIDAssertion) Variant(variant byte, msgAndArgs ...interface{}) *UUIDAssertion

Variant asserts that the JSON node has a string value equals to UUID with the given variant.

func (*UUIDAssertion) Version added in v0.4.0

func (a *UUIDAssertion) Version(version byte, msgAndArgs ...interface{}) *UUIDAssertion

Version asserts that the JSON node has a string value equals to UUID with the given version.

Jump to

Keyboard shortcuts

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