golang_json_assert

package module
v0.0.0-...-96e3cfd Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2020 License: MIT Imports: 4 Imported by: 0

README

Golang Json Assert

golang-json-assert

A Go library for testing JSON strings.

Mission

I could not find any library implementing the "Conform behavior", which checks, if JSON objects are downwards-compatible, therefore testing if there is a semantic versioning major bump change.

Usage

For full specification of the library see pkg/jsonassert_test.go.

In a Nutshell, given to strings, the library can check for strict equality:

actual := `
{
  "name": "Lars",
  "age": 12
}
`

Expect(actual).ToEqual(actual) // returns true

But, It can also check, if a JSON conforms with another. This means, that in theory actual and expected value are schematically compatible. This can be used to ensure that diffrent JSON objects provide some compability.

actual := `
{
  "name": "Lars",
  "age": 12
}
`

expect := `
{
  "age": 12
}
`

Expect(actual).ToConform(expect) // returns true

Contribution

If you feel like there are missing some assertions / specifications, feel free to open an issue / Submit a PR.

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ go test

License

The MIT License (MIT). Please see License File for more information.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UmmarshalToMap

func UmmarshalToMap(src string) map[string]interface{}

func UnmarshalToArray

func UnmarshalToArray(src string) []interface{}

Types

type ActualJson

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

func Expect

func Expect(str string) ActualJson

func (ActualJson) ToConform

func (a ActualJson) ToConform(expectation string) bool

func (ActualJson) ToEqual

func (a ActualJson) ToEqual(expectation string) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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