be_json

package
v0.1.0-alpha Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: MIT Imports: 9 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

be_json

-- import "github.com/expectto/be/be_json"

Package be_json provides Be matchers for expressive assertions on JSON TODO: more detailed explanation what is considered to be JSON here

Usage

func HaveKeyValue
func HaveKeyValue(key any, args ...any) types.BeMatcher

HaveKeyValue is a facade to gomega.HaveKey & gomega.HaveKeyWithValue

func Matcher
func Matcher(args ...any) types.BeMatcher

Matcher is a JSON matcher. "JSON" here means a []byte with JSON data in it By default several input types are available: string() / []byte(), fmt.Stringer, io.Reader

- custom string-based or []byte-based types are available as well

To make it stricter and to specify which format JSON we should expect, you must pass one of transforms as first argument:

- JsonAsBytes/ JsonAsString / JsonAsStringer  / JsonAsReader (for string-like representation)
- JsonAsObject / JsonAsObjects (for map[string]any representation)
type JsonInputType
type JsonInputType uint32
const (
	JsonAsBytes JsonInputType = 1 << iota
	JsonAsString
	JsonAsStringer
	JsonAsReader
	JsonAsObject
	JsonAsObjects
)

Documentation

Overview

Package be_json provides Be matchers for expressive assertions on JSON TODO: more detailed explanation what is considered to be JSON here

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HaveKeyValue

func HaveKeyValue(key any, args ...any) types.BeMatcher

HaveKeyValue is a facade to gomega.HaveKey & gomega.HaveKeyWithValue

func Matcher

func Matcher(args ...any) types.BeMatcher

Matcher is a JSON matcher. "JSON" here means a []byte with JSON data in it By default several input types are available: string(*) / []byte(*), fmt.Stringer, io.Reader

  • custom string-based or []byte-based types are available as well

To make it stricter and to specify which format JSON we should expect, you must pass one of transforms as first argument:

  • JsonAsBytes/ JsonAsString / JsonAsStringer / JsonAsReader (for string-like representation)
  • JsonAsObject / JsonAsObjects (for map[string]any representation)

Types

type JsonInputType

type JsonInputType uint32
const (
	JsonAsBytes JsonInputType = 1 << iota
	JsonAsString
	JsonAsStringer
	JsonAsReader
	JsonAsObject
	JsonAsObjects
)

Jump to

Keyboard shortcuts

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