jsonpath

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package jsonpath provides assertions for jsonpath expressions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(expression string, expected interface{}) func(*http.Response, *http.Request) error

Contains is a convenience function to assert that a jsonpath expression extracts a value in an array

func Equal

func Equal(expression string, expected interface{}) func(*http.Response, *http.Request) error

Equal is a convenience function to assert that a jsonpath expression extracts a value

func GreaterThan

func GreaterThan(expression string, minimumLength int) func(*http.Response, *http.Request) error

GreaterThan asserts that value is greater than the given length, determined by reflect.Len

func JWTHeaderEqual

func JWTHeaderEqual(tokenSelector func(*http.Response) (string, error), expression string, expected interface{}) func(*http.Response, *http.Request) error

JWTHeaderEqual asserts that the JWT header matches the expected value

func JWTPayloadEqual

func JWTPayloadEqual(tokenSelector func(*http.Response) (string, error), expression string, expected interface{}) func(*http.Response, *http.Request) error

JWTPayloadEqual asserts that the JWT payload matches the expected value

func Len

func Len(expression string, expectedLength int) func(*http.Response, *http.Request) error

Len asserts that value is the expected length, determined by reflect.Len

func LessThan

func LessThan(expression string, maximumLength int) func(*http.Response, *http.Request) error

LessThan asserts that value is less than the given length, determined by reflect.Len

func Matches

func Matches(expression string, regexp string) func(*http.Response, *http.Request) error

Matches asserts that the value matches the given regular expression

func NotEqual

func NotEqual(expression string, expected interface{}) func(*http.Response, *http.Request) error

NotEqual is a function to check json path expression value is not equal to given value

func NotPresent

func NotPresent(expression string) func(*http.Response, *http.Request) error

NotPresent asserts that value returned by the expression is not present

func Present

func Present(expression string) func(*http.Response, *http.Request) error

Present asserts that value returned by the expression is present

Types

type AssertionChain

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

AssertionChain supports chaining assertions and root expressions

func Chain

func Chain() *AssertionChain

Chain creates a new assertion chain

func Root

func Root(expression string) *AssertionChain

Root creates a new assertion chain prefixed with the given expression

func (*AssertionChain) Contains

func (r *AssertionChain) Contains(expression string, expected interface{}) *AssertionChain

Contains adds an Contains assertion to the chain

func (*AssertionChain) End

func (r *AssertionChain) End() func(*http.Response, *http.Request) error

End returns an func(*http.Response, *http.Request) error which is a combination of the registered assertions

func (*AssertionChain) Equal

func (r *AssertionChain) Equal(expression string, expected interface{}) *AssertionChain

Equal adds an Equal assertion to the chain

func (*AssertionChain) Matches

func (r *AssertionChain) Matches(expression, regexp string) *AssertionChain

Matches adds an Matches assertion to the chain

func (*AssertionChain) NotEqual

func (r *AssertionChain) NotEqual(expression string, expected interface{}) *AssertionChain

NotEqual adds an NotEqual assertion to the chain

func (*AssertionChain) NotPresent

func (r *AssertionChain) NotPresent(expression string) *AssertionChain

NotPresent adds an NotPresent assertion to the chain

func (*AssertionChain) Present

func (r *AssertionChain) Present(expression string) *AssertionChain

Present adds an Present assertion to the chain

Directories

Path Synopsis
Package http is utility functions for http requests and responses.
Package http is utility functions for http requests and responses.
Package jsonpath is not referenced by user code.
Package jsonpath is not referenced by user code.
Package mocks provides convenience functions for asserting jsonpath expressions
Package mocks provides convenience functions for asserting jsonpath expressions

Jump to

Keyboard shortcuts

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