jsonrequire

package
v1.0.0-beta.41 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Match

func Match(t testing.TB, expectedTemplateFormat string, params map[string]any, actual string)

Match helps to make assertions on JSON strings when some values are not known in advance. For example, when we do the assertion on JSON serialized models, we can't predict the values of fields like IDs or timestamps. In such cases, we can use a "template" with placeholders for these values. See matcher_test.go for examples

Types

type Getter

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

Getter allows to get values from the JSON data.

func NewGetterWithJSON

func NewGetterWithJSON(t testing.TB, jsonString string) *Getter

NewGetterWithJSON creates a new Getter based on JSON string

func (*Getter) GetString

func (g *Getter) GetString(xpath string) string

GetString returns a string value from the data.

Jump to

Keyboard shortcuts

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