Documentation ¶
Index ¶
- Constants
- func Base64GzipToByteReader(input string) (io.ReadCloser, error)
- func ExecuteCommand(input string) (interface{}, error)
- func IndentStr(level int) string
- func ObjectPrintf(message string, obj interface{}) string
- func PrintIndentedLn(indentLevel int, format string, args ...interface{})
- func PrintReport(opts ReportOptions, passed bool, testingDuration time.Duration, ...)
- func PrintSingleTestReport(opts ReportOptions, test *TestResult)
- func PrintYamlObj(object interface{}) (string, error)
- func RecursiveExecuteCommand(input interface{}) (interface{}, error)
- func ShouldShowReport(opts ReportOptions, test *TestResult) bool
- func ToJsonObj(obj interface{}) (map[string]interface{}, error)
- func YamlToJson(i interface{}) interface{}
- type ArrayMatcher
- func (m *ArrayMatcher) Error() string
- func (m *ArrayMatcher) GetPriority() int
- func (m *ArrayMatcher) Match(responseValue interface{}, datastore *DataStore) (bool, DataStore, error)
- func (m *ArrayMatcher) Parse(parentNode interface{}, node map[interface{}]interface{}) error
- func (m *ArrayMatcher) SetError(error string)
- type BinResponseJson
- type BoolMatcher
- func (m *BoolMatcher) Error() string
- func (m *BoolMatcher) GetPriority() int
- func (m *BoolMatcher) Match(responseValue interface{}, datastore *DataStore) (bool, DataStore, error)
- func (m *BoolMatcher) Parse(parentNode interface{}, node map[interface{}]interface{}) error
- func (m *BoolMatcher) SetError(error string)
- type ByteCountWriter
- type Colorizer
- func (c *Colorizer) BrightBlue(input string) string
- func (c *Colorizer) BrightCyan(input string) string
- func (c *Colorizer) BrightGrey(input string) string
- func (c *Colorizer) BrightRed(input string) string
- func (c *Colorizer) BrightWhite(input string) string
- func (c *Colorizer) BrightYellow(input string) string
- func (c *Colorizer) Cyan(input string) string
- func (c *Colorizer) Green(input string) string
- func (c *Colorizer) Red(input string) string
- func (c *Colorizer) Underline(input string) string
- func (c *Colorizer) Yellow(input string) string
- type CommandStack
- type CommandStackFrame
- type DataStore
- type DepthMatchResponse
- type DepthMatchResponseNode
- type ExecutableMatcher
- func (m *ExecutableMatcher) Error() string
- func (m *ExecutableMatcher) GetPriority() int
- func (m *ExecutableMatcher) Match(responseValue interface{}, datastore *DataStore) (bool, DataStore, error)
- func (m *ExecutableMatcher) Parse(parentNode interface{}, node map[interface{}]interface{}) error
- func (m *ExecutableMatcher) SetError(error string)
- type FieldMatcher
- type FieldMatcherConfig
- type FieldMatcherPath
- type FieldMatcherResult
- type FieldPathKey
- type FloatMatcher
- func (m *FloatMatcher) Error() string
- func (m *FloatMatcher) GetPriority() int
- func (m *FloatMatcher) Match(responseValue interface{}, datastore *DataStore) (bool, DataStore, error)
- func (m *FloatMatcher) Parse(parentNode interface{}, node map[interface{}]interface{}) error
- func (m *FloatMatcher) SetError(error string)
- type InputReader
- type IntegerMatcher
- func (m *IntegerMatcher) Error() string
- func (m *IntegerMatcher) GetPriority() int
- func (m *IntegerMatcher) Match(responseValue interface{}, datastore *DataStore) (bool, DataStore, error)
- func (m *IntegerMatcher) Parse(parentNode interface{}, node map[interface{}]interface{}) error
- func (m *IntegerMatcher) SetError(error string)
- type MultiSuiteResult
- type MultiTestSuite
- type NodeCacheObj
- type ObjectMatcher
- func (m *ObjectMatcher) Error() string
- func (m *ObjectMatcher) GetPriority() int
- func (m *ObjectMatcher) Match(responseValue interface{}, datastore *DataStore) (bool, DataStore, error)
- func (m *ObjectMatcher) Parse(parentNode interface{}, node map[interface{}]interface{}) error
- func (m *ObjectMatcher) SetError(error string)
- type ReportOptions
- type ResponseMatcher
- type StringMatcher
- func (m *StringMatcher) Error() string
- func (m *StringMatcher) GetPriority() int
- func (m *StringMatcher) Match(responseValue interface{}, datastore *DataStore) (bool, DataStore, error)
- func (m *StringMatcher) Parse(parentNode interface{}, node map[interface{}]interface{}) error
- func (m *StringMatcher) SetError(error string)
- type SuiteResult
- type TestCase
- func (t *TestCase) CloseWebsocket()
- func (t *TestCase) Execute(testTags []string) (passed bool, result *TestResult, err error)
- func (t *TestCase) GetResolvedTestInput() (interface{}, error)
- func (t *TestCase) GetRestInput(input interface{}) (*InputReader, error)
- func (t *TestCase) GetTestHeaders(inputReader *InputReader) (map[interface{}]interface{}, error)
- func (t *TestCase) GetTestRoute() (string, error)
- func (t *TestCase) GetTestRpcAddr() (string, error)
- func (t *TestCase) GetWebsocketClient() (*websocket.Conn, string, error)
- func (t *TestCase) GetWebsocketInput(input interface{}) (*WSInput, error)
- func (t *TestCase) HasTag(tagList string) bool
- func (t *TestCase) LoadConfig(test *TestCaseCfg) error
- func (t *TestCase) SkipTestOnTags(testTags []string) bool
- func (t *TestCase) StepExecWebsocket(step int, result *TestResult) (passed bool, remaining int, err error)
- func (t *TestCase) ValidateGeneric(response map[string]interface{}) (bool, []*FieldMatcherResult, error)
- func (t *TestCase) ValidateREST(statusCode int, response map[string]interface{}, ...) (bool, []*FieldMatcherResult, error)
- type TestCaseCfg
- type TestCaseResponseCfg
- type TestCaseRpcCfg
- type TestResult
- type TestSuite
- func (t *TestSuite) Close()
- func (t *TestSuite) ExecuteTests(testTags []string) (bool, SuiteResult, error)
- func (t *TestSuite) InitializeDataStore(fixtures string) error
- func (t *TestSuite) LoadFixtures(fixtures string) (map[string]interface{}, error)
- func (t *TestSuite) LoadTests(testFile string, fixtures string) (bool, error)
- func (t *TestSuite) ReloadFile(testFile string, fixtures string) (bool, error)
- type TestSuiteCfg
- type VarStack
- type VarStackFrame
- type WSInput
- type WSMessage
- type WsResponseJson
Constants ¶
View Source
const ( Any = "$any" NotEmpty = "$notEmpty" LT = "$<" LTE = "$<=" GT = "$>" GTE = "$>=" EQ = "$=" // special keywords used in validation object definitions TEST_KEY_TYPE = "type" TEST_KEY_PROPERTIES = "properties" TEST_KEY_LENGTH = "length" TEST_KEY_ITEMS = "items" TEST_KEY_SORTED = "sorted" TEST_KEY_STORE = "storeAs" TEST_KEY_PRIORITY = "priority" TEST_KEY_MATCHES = "matches" TEST_KEY_EXISTS = "exists" TEST_EXEC_KEY_RETURN_CODE = "returns" TEST_EXEC_KEY_BIN_PATH = "bin" TEST_EXEC_KEY_ARGS = "args" ValueErrFmt = "Expected value '%v' did not match the actual value '%v'" PatternErrFmt = "Failed to match actual value '%v' with expected pattern: '%v'" NotEmptyErrFmt = "Expected non-empty value, but got value '%v' instead." ArrayLengthErrFmt = "Expected array with length %v %v but found length %v instead." ReceivedNullErrFmt = "Received null value when non-null value was expected" ExpectedNullErrFmt = "Expected null value when non-null value was returned" MalformedDefinitionFmt = "\nMalformed '%v' field detected on %v" MismatchedMatcher = "Test expected a value type matching '%v' but response field is of type '%v'." BadVarMatcherFmt = "Failed to resolve variable within matcher: %v" BadArrayElementFmt = "\nExpected elements on '%v' to be objects" BadObjectFmt = "\nExpected property '%v' to map to an object" // available field matchers TYPE_INT = "integer" TYPE_NUM = "number" TYPE_STR = "string" TYPE_ARRAY = "array" TYPE_OBJ = "object" TYPE_BOOL = "bool" TYPE_EXEC = "external" )
View Source
const ( MissingDSKeyFmt = "Attempted to retrieve data from data store that does not exist: key: %v" BadIndexDSFmt = "Attempted to index into a data store value with a non-positive or non-integer value: %v" IndexExceedsDSFmt = "Index for data store value exceeds its max length: %v" StatusCodePath = "response.StatusCode" HeadersPath = "response.Header" )
View Source
const ( // Test Config keys CFG_SKIP = "skip" CFG_TAGS = "tags" CFG_RESPONSE_CODE = "code" // Mime types MIME_JSON = "application/json" MIME_TEXT = "text/plain" //Headers HEADER_CONTENT_TYPE = "Content-Type" // MISC RESPONSE_PATH_FMT = "binary-response-*" //DataStore Vars DS_WS_CLIENT = "ws" )
View Source
const ( WS_ENC_BASE64 = "base64gzip" WS_ENC_HEX = "hex" WS_ENC_FILE = "file" WS_ENC_EXTERNAL = "external" WS_MSG_TEXT = "text" WS_MSG_JSON = "json" WS_MSG_BIN = "binary" )
Variables ¶
This section is empty.
Functions ¶
func Base64GzipToByteReader ¶
func Base64GzipToByteReader(input string) (io.ReadCloser, error)
func ExecuteCommand ¶
func ObjectPrintf ¶
func PrintIndentedLn ¶
func PrintReport ¶
func PrintReport(opts ReportOptions, passed bool, testingDuration time.Duration, results []MultiSuiteResult)
func PrintSingleTestReport ¶
func PrintSingleTestReport(opts ReportOptions, test *TestResult)
func PrintYamlObj ¶
func RecursiveExecuteCommand ¶
func RecursiveExecuteCommand(input interface{}) (interface{}, error)
Iterate through an object and execute any command strings that are located. Returns the input object with the command strings expanded to their results
func ShouldShowReport ¶
func ShouldShowReport(opts ReportOptions, test *TestResult) bool
func YamlToJson ¶
func YamlToJson(i interface{}) interface{}
Types ¶
type ArrayMatcher ¶
type ArrayMatcher struct { Length *int64 LengthStr *string Items []interface{} ErrorStr string Exists bool DSName string Sorted bool Priority int }
func (*ArrayMatcher) Error ¶
func (m *ArrayMatcher) Error() string
func (*ArrayMatcher) GetPriority ¶
func (m *ArrayMatcher) GetPriority() int
func (*ArrayMatcher) Match ¶
func (m *ArrayMatcher) Match(responseValue interface{}, datastore *DataStore) (bool, DataStore, error)
func (*ArrayMatcher) Parse ¶
func (m *ArrayMatcher) Parse(parentNode interface{}, node map[interface{}]interface{}) error
func (*ArrayMatcher) SetError ¶
func (m *ArrayMatcher) SetError(error string)
type BinResponseJson ¶
type BinResponseJson struct { Saved string `json:"saved"` Notice []string `json:"NOTICE,omitempty"` Size uint64 `json:"size"` SHA256Sum string `json:"sha256sum"` }
func (*BinResponseJson) GenericJSON ¶
func (bj *BinResponseJson) GenericJSON() map[string]interface{}
type BoolMatcher ¶
type BoolMatcher struct { Value *bool Pattern *string ErrorStr string Exists bool DSName string Priority int }
func (*BoolMatcher) Error ¶
func (m *BoolMatcher) Error() string
func (*BoolMatcher) GetPriority ¶
func (m *BoolMatcher) GetPriority() int
func (*BoolMatcher) Match ¶
func (m *BoolMatcher) Match(responseValue interface{}, datastore *DataStore) (bool, DataStore, error)
func (*BoolMatcher) Parse ¶
func (m *BoolMatcher) Parse(parentNode interface{}, node map[interface{}]interface{}) error
func (*BoolMatcher) SetError ¶
func (m *BoolMatcher) SetError(error string)
type ByteCountWriter ¶
type ByteCountWriter struct {
ByteCount uint64
}
type Colorizer ¶
type Colorizer struct {
Enabled bool
}
func (*Colorizer) BrightBlue ¶
func (*Colorizer) BrightCyan ¶
func (*Colorizer) BrightGrey ¶
func (*Colorizer) BrightWhite ¶
func (*Colorizer) BrightYellow ¶
type CommandStack ¶
type CommandStack struct { Frames []CommandStackFrame Extra string }
func (*CommandStack) Pop ¶
func (s *CommandStack) Pop() *CommandStackFrame
func (*CommandStack) Push ¶
func (s *CommandStack) Push(f CommandStackFrame)
type CommandStackFrame ¶
func (*CommandStackFrame) IsValid ¶
func (f *CommandStackFrame) IsValid() bool
type DepthMatchResponse ¶
type DepthMatchResponse struct { FoundNode DepthMatchResponseNode NodeChain []*DepthMatchResponseNode }
type DepthMatchResponseNode ¶
type ExecutableMatcher ¶
type ExecutableMatcher struct { ReturnCode *int BinPath string PrgmArgs []string ErrorStr string Exists bool DSName string Priority int }
func (*ExecutableMatcher) Error ¶
func (m *ExecutableMatcher) Error() string
func (*ExecutableMatcher) GetPriority ¶
func (m *ExecutableMatcher) GetPriority() int
func (*ExecutableMatcher) Match ¶
func (m *ExecutableMatcher) Match(responseValue interface{}, datastore *DataStore) (bool, DataStore, error)
func (*ExecutableMatcher) Parse ¶
func (m *ExecutableMatcher) Parse(parentNode interface{}, node map[interface{}]interface{}) error
func (*ExecutableMatcher) SetError ¶
func (m *ExecutableMatcher) SetError(error string)
type FieldMatcher ¶
type FieldMatcherConfig ¶
type FieldMatcherConfig struct { Matcher FieldMatcher ObjectKeyPath FieldMatcherPath }
type FieldMatcherPath ¶
type FieldMatcherPath struct { Keys []FieldPathKey IsArrayElement bool Sorted bool IsExecutable bool }
func (*FieldMatcherPath) GetParentPath ¶
func (f *FieldMatcherPath) GetParentPath() string
func (*FieldMatcherPath) GetPath ¶
func (f *FieldMatcherPath) GetPath() string
type FieldMatcherResult ¶
type FieldPathKey ¶
type FloatMatcher ¶
type FloatMatcher struct { Value *float64 Pattern *string Exists bool ErrorStr string DSName string Priority int }
func (*FloatMatcher) Error ¶
func (m *FloatMatcher) Error() string
func (*FloatMatcher) GetPriority ¶
func (m *FloatMatcher) GetPriority() int
func (*FloatMatcher) Match ¶
func (m *FloatMatcher) Match(responseValue interface{}, datastore *DataStore) (bool, DataStore, error)
func (*FloatMatcher) Parse ¶
func (m *FloatMatcher) Parse(parentNode interface{}, node map[interface{}]interface{}) error
func (*FloatMatcher) SetError ¶
func (m *FloatMatcher) SetError(error string)
type InputReader ¶
type IntegerMatcher ¶
type IntegerMatcher struct { Value *int64 Pattern *string Exists bool ErrorStr string DSName string Priority int }
func (*IntegerMatcher) Error ¶
func (m *IntegerMatcher) Error() string
func (*IntegerMatcher) GetPriority ¶
func (m *IntegerMatcher) GetPriority() int
func (*IntegerMatcher) Match ¶
func (m *IntegerMatcher) Match(responseValue interface{}, datastore *DataStore) (bool, DataStore, error)
func (*IntegerMatcher) Parse ¶
func (m *IntegerMatcher) Parse(parentNode interface{}, node map[interface{}]interface{}) error
func (*IntegerMatcher) SetError ¶
func (m *IntegerMatcher) SetError(error string)
type MultiSuiteResult ¶
type MultiSuiteResult struct { Passed bool Error error TestResults SuiteResult TestFile string }
type MultiTestSuite ¶
func NewMultiSuiteTest ¶
func NewMultiSuiteTest(testDir string, fixtures string) (*MultiTestSuite, error)
func (*MultiTestSuite) ExecuteTests ¶
func (t *MultiTestSuite) ExecuteTests(threads int, testTags []string) (bool, []MultiSuiteResult, time.Duration, error)
type NodeCacheObj ¶
type NodeCacheObj struct { Node interface{} PathIndex int }
type ObjectMatcher ¶
type ObjectMatcher struct { Properties map[interface{}]interface{} ErrorStr string Exists bool DSName string Sorted bool Priority int }
func (*ObjectMatcher) Error ¶
func (m *ObjectMatcher) Error() string
func (*ObjectMatcher) GetPriority ¶
func (m *ObjectMatcher) GetPriority() int
func (*ObjectMatcher) Match ¶
func (m *ObjectMatcher) Match(responseValue interface{}, datastore *DataStore) (bool, DataStore, error)
func (*ObjectMatcher) Parse ¶
func (m *ObjectMatcher) Parse(parentNode interface{}, node map[interface{}]interface{}) error
func (*ObjectMatcher) SetError ¶
func (m *ObjectMatcher) SetError(error string)
type ReportOptions ¶
type ResponseMatcher ¶
type ResponseMatcher struct { DS *DataStore Config []*FieldMatcherConfig }
func (*ResponseMatcher) Match ¶
func (r *ResponseMatcher) Match(response interface{}) (bool, []*FieldMatcherResult, error)
Match Validates our test pattern against the actual JSON response
func (*ResponseMatcher) SortConfigs ¶
func (r *ResponseMatcher) SortConfigs()
type StringMatcher ¶
func (*StringMatcher) Error ¶
func (m *StringMatcher) Error() string
func (*StringMatcher) GetPriority ¶
func (m *StringMatcher) GetPriority() int
func (*StringMatcher) Match ¶
func (m *StringMatcher) Match(responseValue interface{}, datastore *DataStore) (bool, DataStore, error)
func (*StringMatcher) Parse ¶
func (m *StringMatcher) Parse(parentNode interface{}, node map[interface{}]interface{}) error
func (*StringMatcher) SetError ¶
func (m *StringMatcher) SetError(error string)
type SuiteResult ¶
type TestCase ¶
type TestCase struct { Config TestCaseCfg IsRPC bool ResponseHeaderMatcher ResponseMatcher StatusCodeMatcher ResponseMatcher ResponseMatcher ResponseMatcher GlobalDataStore *DataStore Tags map[string]bool }
func (*TestCase) CloseWebsocket ¶
func (t *TestCase) CloseWebsocket()
func (*TestCase) Execute ¶
func (t *TestCase) Execute(testTags []string) (passed bool, result *TestResult, err error)
func (*TestCase) GetResolvedTestInput ¶
Returns a new input object with all included variables resolved
func (*TestCase) GetRestInput ¶
func (t *TestCase) GetRestInput(input interface{}) (*InputReader, error)
func (*TestCase) GetTestHeaders ¶
func (t *TestCase) GetTestHeaders(inputReader *InputReader) (map[interface{}]interface{}, error)
func (*TestCase) GetTestRoute ¶
func (*TestCase) GetTestRpcAddr ¶
func (*TestCase) GetWebsocketClient ¶
func (*TestCase) GetWebsocketInput ¶
func (*TestCase) HasTag ¶
tag string can contain 1 or more tags separated by ",". This syntax will OR the tags.
func (*TestCase) LoadConfig ¶
func (t *TestCase) LoadConfig(test *TestCaseCfg) error
func (*TestCase) SkipTestOnTags ¶
func (*TestCase) StepExecWebsocket ¶
func (*TestCase) ValidateGeneric ¶
func (t *TestCase) ValidateGeneric(response map[string]interface{}) (bool, []*FieldMatcherResult, error)
func (*TestCase) ValidateREST ¶
type TestCaseCfg ¶
type TestCaseCfg struct { Name string `yaml:"name"` Description string `yaml:"description"` ExitOnRun bool `yaml:"exit"` Skip bool `yaml:"skip"` Input map[interface{}]interface{} `yaml:"input"` FormInput bool `yaml:"formInput"` Tags []string `yaml:"tags"` Headers map[interface{}]interface{} `yaml:"headers"` Route string `yaml:"route"` Method string `yaml:"method"` RPC TestCaseRpcCfg `yaml:"rpc"` Websocket bool `yaml:"websocket"` Response TestCaseResponseCfg `yaml:"response"` }
type TestCaseResponseCfg ¶
type TestCaseResponseCfg struct { // status code could end up being either a number or an object defining a validation definition StatusCode interface{} `yaml:"code"` IsBinary bool `yaml:"binary"` FilePath string `yaml:"filePath"` Payload map[interface{}]interface{} `yaml:"payload"` Headers map[interface{}]interface{} `yaml:"headers"` }
type TestCaseRpcCfg ¶
type TestResult ¶
type TestSuite ¶
func (*TestSuite) ExecuteTests ¶
func (t *TestSuite) ExecuteTests(testTags []string) (bool, SuiteResult, error)
func (*TestSuite) InitializeDataStore ¶
func (*TestSuite) LoadFixtures ¶
type TestSuiteCfg ¶
type TestSuiteCfg struct {
Tests []TestCaseCfg `yaml:"tests"`
}
type VarStack ¶
type VarStack struct { Frames []VarStackFrame Extra string }
func (*VarStack) Pop ¶
func (s *VarStack) Pop() *VarStackFrame
func (*VarStack) Push ¶
func (s *VarStack) Push(f VarStackFrame)
type VarStackFrame ¶
func (*VarStackFrame) IsValid ¶
func (f *VarStackFrame) IsValid() bool
type WSMessage ¶
type WSMessage struct { Payload interface{} `yaml:"payload" json:"payload"` Args []string `yaml:"args" json:"args"` WriteOnly bool `yaml:"WriteOnly" json:"WriteOnly"` ReadOnly bool `yaml:"readOnly" json:"readOnly"` Response string `yaml:"response" json:"response"` MessageType string `yam:"type" json:"type"` Encoding string `yaml:"encoding" json:"encoding"` FilePath string `yaml:"filePath" json:"filePath"` }
type WsResponseJson ¶
type WsResponseJson struct {
Responses []map[string]interface{} `json:"responses"`
}
Source Files ¶
Click to show internal directories.
Click to hide internal directories.