Documentation
¶
Index ¶
- Variables
- func Contain(container []interface{}, i interface{}) bool
- func LoadYAML(y []byte, p interface{})
- func RegexpNamedCaptures(r *regexp.Regexp, s string) []map[string]string
- func Run(args []string) []byte
- func RunItemValidationTest(t *testing.T, i *sdp.Item)
- func RunSourceTests(t *testing.T, tests []SourceTest, source discovery.Source)
- func Validate(validValues interface{}, value interface{}, errorString string)
- type ExpectedError
- type ExpectedItems
- type SourceTest
Constants ¶
This section is empty.
Variables ¶
View Source
var LocalContext string
Functions ¶
func Contain ¶
func Contain(container []interface{}, i interface{}) bool
Contain will return true if a slice contains a a value
func RegexpNamedCaptures ¶
RegexpNamedCaptures Helper function for getting named captures out into a map in a sane way from a multiline regex i.e. [
{
"capture1": "hello",
"capture2": "dylan"
},
{
"capture1": "hello",
"capture2": "francis"
},
]
func Run ¶
Run runs a command and returns only the bytemap, panicing on error
Accepts an array of strings which will be joined by spaces
func RunItemValidationTest ¶
RunItemValidationTest Checks an item to ensure it is a valid SDP item. This includes checking that all required attributes are populated
func RunSourceTests ¶
func RunSourceTests(t *testing.T, tests []SourceTest, source discovery.Source)
Types ¶
type ExpectedError ¶
type ExpectedError struct {
// The expected type of the error
Type sdp.ItemRequestError_ErrorType
// A pointer to a regex that will be used to validate the error message,
// leave as `nil`if you don't want to check this
ErrorStringRegex *regexp.Regexp
// The context that the error should come from. Leave as "" if you don't
// want to check this
Context string
}
type ExpectedItems ¶
type ExpectedItems struct {
// The expected number of items
NumItems int
// A list of expected attributes for the items, will be checked in order
// with the first set of attributes neeing to match those of the first item
// etc. Note that this doesn't need to have the same number of entries as
// there are items
ExpectedAttributes []map[string]interface{}
}
type SourceTest ¶
type SourceTest struct {
// Name of the test for logging
Name string
// The context to be passed to the Get() request
ItemContext string
// The query to be passed
Query string
// The method that should be used
Method sdp.RequestMethod
// Details of the expected error, `nil` means no error
ExpectedError *ExpectedError
// The expected items
ExpectedItems *ExpectedItems
}
Click to show internal directories.
Click to hide internal directories.