Documentation ¶
Overview ¶
package testcases defines the Case data structure, and a public function for instantiating slices of Cases from JSON test specifications in directory trees on the filesystem.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Case ¶
type Case struct { Config CaseConfig Result Result Skipped bool Done chan struct{} }
Case is an executable test case. The Config property can be accessed to get information about the case scenario.
func All ¶
func All(opts *TestsCasesOpts) ([]*Case, error)
All returns an array of executable test cases for the directory tree specified by testsRoot. Tests will be executable against the given target.
Cases recursively traverses down the testsRoot directory and collects all test cases it finds. *Any* file in the dir tree which is not a directory or a well-formed JSON test case will cause this function to return an error.
func NewCase ¶
func NewCase(config CaseConfig) *Case
NewCase instantiates and returns a Case struct.
func (*Case) Exec ¶
Exec executes a test Case and populates the Case's Result struct. The Result is unsuccessful and an error is stored in any of three cases:
- The response was invalid for the request according to the OAPI schema.
- The response contents did not satisfy the Case's expectations (if any).
- Other reasons pertaining to the case specification or the environment. For example, the case contains an invalid route or cannot be unmarshaled (is ill-formed), or a network condition prevented contacting the target.
Otherwise, the Result is marked as a Success and the Error is left nil.
func (Case) ResultsPretty ¶ added in v0.2.0
ResultsPretty returns human-readable test results output suitable for printing to a CLI.
type CaseConfig ¶
type CaseConfig struct { Method string Route string AwaitSlot int QueryParams map[string]string ReqBody interface{} ExpectedRespStatus int ExpectedRespBody interface{} }
CaseConfig describes a test scenario.
type TestSpecificationError ¶
func (TestSpecificationError) Error ¶
func (e TestSpecificationError) Error() string
type TestsCasesOpts ¶
type TestsCasesOpts struct { // target is a URL hosting an Ethereum 2.0 API where test requests should // be sent. For example, http://localhost:5051 Target string // TestsRemote is a URL to a zip file containing a directory tree // containing well-specified JSON tests cases. TestsRemote string // OutDir is the directory where zip files will be downloaded, and // unzipped. OutDir string // testsRoot is a file path to a directory tree containing well-specified // JSON tests cases. TestsRoot string }
TestsCasesOpts are used to configure statically defined test cases with dynamic values at runtime.
type UnimplementedOperationError ¶
type UnimplementedOperationError struct {
// contains filtered or unexported fields
}
func (UnimplementedOperationError) Error ¶
func (e UnimplementedOperationError) Error() string