Documentation ¶
Index ¶
- func AssertResponse(t *testing.T, expected interface{}, responseBody []byte) bool
- func NewRunner(baseUrl string, config RunnerConfig) *httpRunner
- type AssertResponseFunc
- type IDocGenerator
- func NewRamlGenerator(seed raml.APIDefinition) IDocGenerator
- func NewSwaggerGenerator(seed spec.Swagger, marshaller MarshallerFunc) IDocGenerator
- func NewSwaggerGeneratorJSON(seed spec.Swagger) IDocGenerator
- func NewSwaggerGeneratorJSONIndent(seed spec.Swagger) IDocGenerator
- func NewSwaggerGeneratorYAML(seed spec.Swagger) IDocGenerator
- type IHttpClient
- type IHttpClientFunc
- type INameable
- type ITaggable
- type ITestRunner
- type MarshallerFunc
- type Param
- type ParamMap
- type RunnerConfig
- type Setuppable
- type Teardownable
- type Test
- type TestCase
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertResponse ¶
AssertResponse checks that given expected object contains the same data as provided responseBody.
func NewRunner ¶
func NewRunner(baseUrl string, config RunnerConfig) *httpRunner
NewRunner creates new instance of HTTP runner
Types ¶
type AssertResponseFunc ¶
AssertResponseFunc defines function that asserts that expected object equals to given response body
type IDocGenerator ¶
IDocGenerator describes a generator of documentation uses test suite as a source of information about API endpoints
func NewRamlGenerator ¶
func NewRamlGenerator(seed raml.APIDefinition) IDocGenerator
NewRamlGenerator creates an instance of RAML generator seed as used as a source of initial data for resulting doc
func NewSwaggerGenerator ¶
func NewSwaggerGenerator(seed spec.Swagger, marshaller MarshallerFunc) IDocGenerator
NewSwaggerGenerator creates a new instance of Swagger generator with given marshaller (may be JSON marshaller or YAML marshaller or whatever)
func NewSwaggerGeneratorJSON ¶
func NewSwaggerGeneratorJSON(seed spec.Swagger) IDocGenerator
NewSwaggerGeneratorJSON initializes new generator with initial swagger spec as a seed. The generator produces JSON output with no indentation
func NewSwaggerGeneratorJSONIndent ¶
func NewSwaggerGeneratorJSONIndent(seed spec.Swagger) IDocGenerator
NewSwaggerGeneratorJSONIndent initializes new generator with initial swagger spec as a seed. The generator produces indented JSON output
func NewSwaggerGeneratorYAML ¶
func NewSwaggerGeneratorYAML(seed spec.Swagger) IDocGenerator
NewSwaggerGeneratorYAML initializes new generator with initial swagger spec as a seed. The generator produces YAML output
type IHttpClient ¶
IHttpClient defines an interface of HTTP client that can fire HTTP requests and return responses.
type IHttpClientFunc ¶
IHttpClientFunc implements IHttpClient in a functional way
type INameable ¶
type INameable interface {
Name() string
}
INameable is an interface that defines that entity can provide its name. Used by test runner to define name of the test.
type ITaggable ¶
type ITaggable interface {
Tag() string
}
ITaggable is an interface that can tell doc generator that some test provides a tag. Usable for swagger documentation where tags help to group API endpoints
type ITestRunner ¶
ITestRunner is responsible for - receive a suite or suites - prepare some conditions to run suites (like setup frisby or whatsoever) - run tests of the suite
type MarshallerFunc ¶
type RunnerConfig ¶
type RunnerConfig struct { DefaultHeaders map[string]string HttpClient IHttpClient }
RunnerConfig contains list of possible options that can be used to initialize the Runner
type Setuppable ¶
type Setuppable interface {
SetUp() error
}
ISetuppable defines interface for tests that have setup logic
If you need to run some preparation logic - this is the right place to do
type Teardownable ¶
type Teardownable interface {
TearDown() error
}
ITeardownable defines interface for tests that have teardown logic
Good place to put some cleanup logic if you need to
type Test ¶
Test defines an interface of API test definition.
Responsibility of api test is to provide some meta data about API endpoint and collection of test cases that describe concrete usage of that endpoint.
type TestCase ¶
type TestCase struct { Description string Headers ParamMap QueryParams ParamMap PathParams ParamMap RequestBody interface{} ExpectedHttpCode int ExpectedHeaders map[string]string ExpectedData interface{} // AssertResponse is a custom assertion logic that can be used // instead of ExpectedData. If provided, it is fully responsible // for processing of API response payload and assertion with // expected data. AssertResponse AssertResponseFunc }
TestCase provides use case of some API endpoint: input and expected output.
Test case knows nothing about API endpoint itself. Path of an API endpoint and its description must be provided by Test.
Ideally each different error that API endpoint can return should be described by a test case.