check

package module
v0.0.0-...-eb12b4a Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2016 License: MIT Imports: 4 Imported by: 0

README

wercker status Build Status GoDoc GoCover GoReportCard

Check

Check adds new checkers for the labix check.v1 testing library

HasKey

HasKey checks if a key exists in a map[string]interface{} typed map

example:
obtained := map[string]interface{}{
    "id":  1234,
    "foo": "abc",
    "bar": nil,
}

c.Assert(obtained, HasKey, []string{"foo", "bar"})

Each

Each iterates over a slice/array and runs the embedded checker for each record All record must match to get a positive check result.

example with the HasKey chained:
obtained := []map[string]interface{}{
    {
        "id":  1234,
        "foo": "abc",
        "bar": nil,
    }, {
        "id":  5678,
        "foo": "xyz",
        "bar": "aaa",
    },
}
c.Assert(obtained, Each(HasKey), []string{"foo", "bar"})

Any

Any iterates over a slice/array and runs the embedded checker for each record. One or more records must match to get a positive match.

example with the HasKey chained:
obtained := []string{"bar", "foo"}
c.Assert(obtained, Any(Equals), "foo")

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HasKey checkv1.Checker = &keyChecker{
	&checkv1.CheckerInfo{Name: "HasKey", Params: []string{"obtained", "keys"}},
}

HasKey checker checks if a set of key names exists in a map.

For example:

    a := map[string]interface{}{
			"foo": 124,
			"bar": "test",
		}
    c.Assert(a, HasKey, []string{"foo", "bar"})

Functions

func Any

func Any(checker checkv1.Checker) checkv1.Checker

Any checker loops over a slice an applies the provided checker on any element. If one of the elements in the slice matches the provided checker it will succeed otherwise fail

For example:

a := []string{"a", "a"}
c.Assert(a, Any(Equals), b)

func Each

func Each(checker checkv1.Checker) checkv1.Checker

Each checker loops over a slice an applies the provided checker on each element.

For example:

a := []string{"a", "a"}
c.Assert(a, Each(Equals), b)

Types

This section is empty.

Jump to

Keyboard shortcuts

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