testing

package
v0.0.1-alpha.3 Latest Latest
Warning

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

Go to latest
Published: May 31, 2016 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ExpectFieldIsValid = func(object map[string]interface{}, field string, val interface{}) {
	object[field] = val
	testContext := context.NewStandard()
	standardValidator, err := validator.NewStandard(testContext)
	gomega.Expect(err).To(gomega.BeNil())
	objectParser, err := parser.NewStandardObject(testContext, &object)
	gomega.Expect(err).To(gomega.BeNil())
	reportAndFailOnErrors(testContext, "Initialization:")
	parsedObject, err := types.Parse(objectParser)
	gomega.Expect(err).To(gomega.BeNil())
	reportAndFailOnErrors(testContext, "Parsing:")
	parsedObject.Validate(standardValidator)
	reportAndFailOnErrors(testContext, "Validation:")
}
View Source
var ExpectFieldNotValid = func(object map[string]interface{}, field string, val interface{}, expectedErrors []*service.Error) {
	object[field] = val
	testContext := context.NewStandard()
	standardValidator, err := validator.NewStandard(testContext)
	gomega.Expect(err).To(gomega.BeNil())
	objectParser, err := parser.NewStandardObject(testContext, &object)
	gomega.Expect(err).To(gomega.BeNil())
	reportAndFailOnErrors(testContext, "Initialization:")
	parsedObject, err := types.Parse(objectParser)
	gomega.Expect(err).To(gomega.BeNil())
	parsedObject.Validate(standardValidator)
	gomega.Expect(testContext.Errors()).ToNot(gomega.BeEmpty())
	gomega.Expect(testContext.Errors()).To(gomega.HaveLen(len(expectedErrors)))
	for _, expectedError := range expectedErrors {
		gomega.Expect(testContext.Errors()).To(gomega.ContainElement(expectedError))
	}
}
View Source
var ParseAndNormalize = func(object map[string]interface{}, field string, val interface{}) data.Datum {
	object[field] = val
	testContext := context.NewStandard()
	standardValidator, err := validator.NewStandard(testContext)
	gomega.Expect(err).To(gomega.BeNil())
	objectParser, err := parser.NewStandardObject(testContext, &object)
	gomega.Expect(err).To(gomega.BeNil())
	reportAndFailOnErrors(testContext, "Initialization:")
	parsedObject, err := types.Parse(objectParser)
	gomega.Expect(err).To(gomega.BeNil())
	reportAndFailOnErrors(testContext, "Parsing:")
	parsedObject.Validate(standardValidator)
	reportAndFailOnErrors(testContext, "Validate:")
	standardNormalizer, err := normalizer.NewStandard(testContext)
	gomega.Expect(err).To(gomega.BeNil())
	parsedObject.Normalize(standardNormalizer)
	return parsedObject
}

Functions

func ComposeError

func ComposeError(expectedError *service.Error, source string, meta interface{}) *service.Error

func RawBaseObject

func RawBaseObject() map[string]interface{}

Types

This section is empty.

Jump to

Keyboard shortcuts

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