Documentation
¶
Index ¶
- func NewAvroEncoder[T any](schema *avro.Schema) func([]byte) ([]byte, error)
- type APIFeature
- func (f *APIFeature) IAmAuthorised() error
- func (f *APIFeature) IAmNotAuthorised() error
- func (f *APIFeature) IDelete(path string) error
- func (f *APIFeature) IGet(path string) error
- func (f *APIFeature) IPatch(path string, body *godog.DocString) error
- func (f *APIFeature) IPostToWithBody(path string, body *godog.DocString) error
- func (f *APIFeature) IPut(path string, body *godog.DocString) error
- func (f *APIFeature) ISetTheHeaderTo(header, value string) error
- func (f *APIFeature) IShouldReceiveTheFollowingJSONResponse(expectedAPIResponse *godog.DocString) error
- func (f *APIFeature) IShouldReceiveTheFollowingJSONResponseWithStatus(expectedCodeStr string, expectedBody *godog.DocString) error
- func (f *APIFeature) IShouldReceiveTheFollowingResponse(expectedAPIResponse *godog.DocString) error
- func (f *APIFeature) IUseAServiceAuthToken(serviceAuthToken string) error
- func (f *APIFeature) IUseAnXFlorenceUserToken(xFlorenceToken string) error
- func (f *APIFeature) RegisterSteps(ctx *godog.ScenarioContext)
- func (f *APIFeature) Reset()
- func (f *APIFeature) TheHTTPStatusCodeShouldBe(expectedCodeStr string) error
- func (f *APIFeature) TheResponseHeaderShouldBe(headerName, expectedValue string) error
- type AuthorizationFeature
- type Check
- type Chrome
- type DynamicValidator
- type ErrorFeature
- func (t *ErrorFeature) Errorf(format string, args ...interface{})
- func (t *ErrorFeature) Helper()
- func (t *ErrorFeature) Log(_ ...interface{})
- func (t *ErrorFeature) Logf(format string, args ...interface{})
- func (t *ErrorFeature) Name() string
- func (t *ErrorFeature) Reset()
- func (t *ErrorFeature) StepError() error
- type EventEncoder
- type HealthCheckTest
- type KafkaEncoderOption
- type KafkaFeature
- type KafkaOptions
- type KafkaScenario
- type MongoCollectionDeletedDocs
- type MongoDeletedDocs
- type MongoFeature
- func (m *MongoFeature) Close() error
- func (m *MongoFeature) GetConnectionString() (string, error)
- func (m *MongoFeature) RegisterSteps(ctx *godog.ScenarioContext)
- func (m *MongoFeature) RemoveAllDataFromCollections(collectionNames string) error
- func (m *MongoFeature) RemoveAllDataFromDatabase() error
- func (m *MongoFeature) Reset() error
- func (m *MongoFeature) ResetCollections(ctx context.Context, databaseName string, collectionNames []string) (*MongoDeletedDocs, error)
- func (m *MongoFeature) ResetDatabase(ctx context.Context, databaseName string) (*MongoDeletedDocs, error)
- func (m *MongoFeature) TheFollowingDocumentExistsInTheCollection(collectionName string, document *godog.DocString) error
- type MongoOptions
- type RedisFeature
- type RedisOptions
- type ServiceInitialiser
- type UIFeature
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAvroEncoder ¶
NewAvroEncoder creates a EventEncoder that encodes the model supplied using the supplied avro schema
Types ¶
type APIFeature ¶
type APIFeature struct {
ErrorFeature
Initialiser ServiceInitialiser
HTTPResponse *http.Response
BeforeRequestHook func() error
StartTime time.Time
HealthCheckInterval time.Duration
ExpectedResponseTime time.Duration
// contains filtered or unexported fields
}
APIFeature contains the information needed to test REST API requests
func NewAPIFeature ¶
func NewAPIFeature(initialiser ServiceInitialiser) *APIFeature
NewAPIFeature returns a new APIFeature, takes a function to retrieve the bound handler just before a request is made
func NewAPIFeatureWithHandler ¶
func NewAPIFeatureWithHandler(handler http.Handler) *APIFeature
NewAPIFeatureWithHandler create a new APIFeature with a handler already bound with your endpoints
func (*APIFeature) IAmAuthorised ¶
func (f *APIFeature) IAmAuthorised() error
IAmAuthorised sets the Authorization header to a bogus token
func (*APIFeature) IAmNotAuthorised ¶
func (f *APIFeature) IAmNotAuthorised() error
IAmNotAuthorised removes any Authorization header set in the request headers
func (*APIFeature) IDelete ¶ added in v0.4.0
func (f *APIFeature) IDelete(path string) error
IDelete makes a DELETE request to the provided path with the current headers
func (*APIFeature) IGet ¶
func (f *APIFeature) IGet(path string) error
IGet makes a get request to the provided path with the current headers
func (*APIFeature) IPatch ¶ added in v0.4.1
func (f *APIFeature) IPatch(path string, body *godog.DocString) error
IPatch makes a PATCH request to the provided path with the current headers and the body provided
func (*APIFeature) IPostToWithBody ¶
func (f *APIFeature) IPostToWithBody(path string, body *godog.DocString) error
IPostToWithBody makes a POST request to the provided path with the current headers and the body provided
func (*APIFeature) IPut ¶ added in v0.4.0
func (f *APIFeature) IPut(path string, body *godog.DocString) error
IPut makes a PUT request to the provided path with the current headers and the body provided
func (*APIFeature) ISetTheHeaderTo ¶
func (f *APIFeature) ISetTheHeaderTo(header, value string) error
ISetTheHeaderTo is a default step used to set a header and associated value for the next request
func (*APIFeature) IShouldReceiveTheFollowingJSONResponse ¶
func (f *APIFeature) IShouldReceiveTheFollowingJSONResponse(expectedAPIResponse *godog.DocString) error
IShouldReceiveTheFollowingJSONResponse asserts that the response body and expected response body are equal. This also validates any "{{DYNAMIC_TIMESTAMP}}" fields.
func (*APIFeature) IShouldReceiveTheFollowingJSONResponseWithStatus ¶
func (f *APIFeature) IShouldReceiveTheFollowingJSONResponseWithStatus(expectedCodeStr string, expectedBody *godog.DocString) error
IShouldReceiveTheFollowingJSONResponseWithStatus asserts the response code and body match the expectation. This also validates any "{{DYNAMIC_TIMESTAMP}}" fields.
func (*APIFeature) IShouldReceiveTheFollowingResponse ¶
func (f *APIFeature) IShouldReceiveTheFollowingResponse(expectedAPIResponse *godog.DocString) error
IShouldReceiveTheFollowingResponse asserts the response body and expected response body are equal
func (*APIFeature) IUseAServiceAuthToken ¶ added in v0.6.0
func (f *APIFeature) IUseAServiceAuthToken(serviceAuthToken string) error
func (*APIFeature) IUseAnXFlorenceUserToken ¶ added in v0.6.0
func (f *APIFeature) IUseAnXFlorenceUserToken(xFlorenceToken string) error
func (*APIFeature) RegisterSteps ¶
func (f *APIFeature) RegisterSteps(ctx *godog.ScenarioContext)
RegisterSteps binds the APIFeature steps to the godog context to enable usage in the component tests
func (*APIFeature) TheHTTPStatusCodeShouldBe ¶
func (f *APIFeature) TheHTTPStatusCodeShouldBe(expectedCodeStr string) error
TheHTTPStatusCodeShouldBe asserts that the status code of the response matches the expected code
func (*APIFeature) TheResponseHeaderShouldBe ¶
func (f *APIFeature) TheResponseHeaderShouldBe(headerName, expectedValue string) error
TheResponseHeaderShouldBe asserts the response header matches the expectation
type AuthorizationFeature ¶
type AuthorizationFeature struct {
ErrorFeature
FakeAuthService *httpfake.HTTPFake
FakePermissionsAPI *authorisationtest.FakePermissionsAPI
}
func NewAuthorizationFeature ¶
func NewAuthorizationFeature() *AuthorizationFeature
func (*AuthorizationFeature) Close ¶
func (f *AuthorizationFeature) Close()
func (*AuthorizationFeature) RegisterDefaultPermissionsBundle ¶ added in v0.25.0
func (f *AuthorizationFeature) RegisterDefaultPermissionsBundle() error
func (*AuthorizationFeature) RegisterSteps ¶
func (f *AuthorizationFeature) RegisterSteps(ctx *godog.ScenarioContext)
func (*AuthorizationFeature) Reset ¶
func (f *AuthorizationFeature) Reset()
type Check ¶ added in v0.24.0
type Check struct {
Name string `json:"name"`
Status string `json:"status"`
StatusCode int `json:"status_code"`
Message string `json:"message"`
LastChecked *time.Time `json:"last_checked"`
LastSuccess *time.Time `json:"last_success"`
LastFailure *time.Time `json:"last_failure"`
}
Check represents a health status of a registered app that mimics the real check struct
type Chrome ¶ added in v0.6.5
type Chrome struct {
ExecAllocatorCanceller context.CancelFunc
CtxCanceller context.CancelFunc
Ctx context.Context
}
Chrome contains Chrome session-related resources
type DynamicValidator ¶ added in v0.28.0
DynamicValidator represents a validator for dynamic placeholder values in JSON. It contains a validation function to check if a value is valid and a placeholder string to replace valid values with for comparison.
type ErrorFeature ¶
func (*ErrorFeature) Errorf ¶
func (t *ErrorFeature) Errorf(format string, args ...interface{})
func (*ErrorFeature) Helper ¶ added in v0.3.0
func (t *ErrorFeature) Helper()
func (*ErrorFeature) Log ¶ added in v0.3.0
func (t *ErrorFeature) Log(_ ...interface{})
func (*ErrorFeature) Logf ¶ added in v0.3.0
func (t *ErrorFeature) Logf(format string, args ...interface{})
func (*ErrorFeature) Name ¶ added in v0.3.0
func (t *ErrorFeature) Name() string
func (*ErrorFeature) Reset ¶ added in v0.8.0
func (t *ErrorFeature) Reset()
func (*ErrorFeature) StepError ¶
func (t *ErrorFeature) StepError() error
type EventEncoder ¶
EventEncoder represents a function that can take in a JSON representation and output an encoded message
type HealthCheckTest ¶ added in v0.24.0
type HealthCheckTest struct {
Status string `json:"status"`
Version healthcheck.VersionInfo `json:"version"`
Uptime time.Duration `json:"uptime"`
StartTime time.Time `json:"start_time"`
Checks []*Check `json:"checks"`
}
HealthCheckTest represents a test healthcheck struct that mimics the real healthcheck struct
type KafkaEncoderOption ¶
type KafkaEncoderOption struct {
Topic string
Encoding string // Eg, Avro
Encoder EventEncoder
}
KafkaEncoderOption links an envent Encoder to a topic and encoding type
type KafkaFeature ¶
type KafkaFeature struct {
KafkaVersion string
EventEncoders map[string]map[string]EventEncoder
// contains filtered or unexported fields
}
KafkaFeature represents a component test feature that tests kafka functionality via testcontainers
func NewKafkaFeature ¶
func NewKafkaFeature(opts *KafkaOptions) *KafkaFeature
NewKafkaFeature creates a new feature with the supplied optional configuration options
func (*KafkaFeature) Close ¶
func (kf *KafkaFeature) Close() error
Close stops the kafka testcontainer
func (*KafkaFeature) GetBrokers ¶
func (kf *KafkaFeature) GetBrokers(ctx context.Context) []string
GetBrokers returns the kafka brokers of the underlying testcontainers instance. I.e. these are the addresses of the brokers which can be used for the app under test's kafka client
func (*KafkaFeature) NewScenario ¶
func (kf *KafkaFeature) NewScenario() *KafkaScenario
NewScenario initiates a new KafkaScenario with features scoped to the current schenario
type KafkaOptions ¶
type KafkaOptions struct {
ContainerName string
KafkaVersion string
Encoders []KafkaEncoderOption
}
KafkaOptions are optional configuration options for the kafka feature initialisation If no encoders are supplied for a topic then the default encoding of JSON is assumed for that topic
type KafkaScenario ¶
type KafkaScenario struct {
KafkaFeature *KafkaFeature
// contains filtered or unexported fields
}
KafkaScenario represents the kafka features scoped to the currently running scenario
func (*KafkaScenario) Close ¶
func (ks *KafkaScenario) Close(ctx context.Context) error
Close cleans up any consumers and producers being used by the current scenairo once finished with
func (*KafkaScenario) GetMappedTopic ¶
func (ks *KafkaScenario) GetMappedTopic(topic string) string
GetMappedTopic returns a topic that has been mapped in the current scenario. If this is the first time it has been called it will create a new random mappping. Subsequent calls return the same value.
func (*KafkaScenario) RegisterSteps ¶
func (ks *KafkaScenario) RegisterSteps(ctx *godog.ScenarioContext)
RegisterSteps adds the kafka feature's steps to the godog ScenarioContext
type MongoCollectionDeletedDocs ¶ added in v0.8.0
MongoCollectionDeletedDocs contains the number of document deleted from collection
type MongoDeletedDocs ¶ added in v0.8.0
type MongoDeletedDocs struct {
Database string
Count int64
Collections []MongoCollectionDeletedDocs
}
MongoDeletedDocs contains a list of counts for all deleted documents against a given collection of a mongo database
type MongoFeature ¶
type MongoFeature struct {
Server *testMongo.MongoDBContainer
Client mongo.Client
Database *mongo.Database
}
MongoFeature is a struct containing a mongo database in a container
func NewMongoFeature ¶
func NewMongoFeature(mongoOptions MongoOptions) *MongoFeature
NewMongoFeature creates a new mongo database in a container using the supplied options
func (*MongoFeature) Close ¶
func (m *MongoFeature) Close() error
Close stops the container mongo database
func (*MongoFeature) GetConnectionString ¶
func (m *MongoFeature) GetConnectionString() (string, error)
GetConnectionString returns the MongoDB connection string for the container
func (*MongoFeature) RegisterSteps ¶
func (m *MongoFeature) RegisterSteps(ctx *godog.ScenarioContext)
func (*MongoFeature) RemoveAllDataFromCollections ¶ added in v0.8.0
func (m *MongoFeature) RemoveAllDataFromCollections(collectionNames string) error
func (*MongoFeature) RemoveAllDataFromDatabase ¶ added in v0.8.0
func (m *MongoFeature) RemoveAllDataFromDatabase() error
func (*MongoFeature) Reset ¶
func (m *MongoFeature) Reset() error
Reset is currently not implemented
func (*MongoFeature) ResetCollections ¶ added in v0.8.0
func (m *MongoFeature) ResetCollections(ctx context.Context, databaseName string, collectionNames []string) (*MongoDeletedDocs, error)
ResetCollections removes all data in all collections specified within database
func (*MongoFeature) ResetDatabase ¶ added in v0.8.0
func (m *MongoFeature) ResetDatabase(ctx context.Context, databaseName string) (*MongoDeletedDocs, error)
ResetDatabase removes all data in all collections within database
func (*MongoFeature) TheFollowingDocumentExistsInTheCollection ¶
func (m *MongoFeature) TheFollowingDocumentExistsInTheCollection(collectionName string, document *godog.DocString) error
type MongoOptions ¶
MongoOptions contains a set of options required to create a new MongoFeature
type RedisFeature ¶ added in v0.21.0
type RedisFeature struct {
Server *testRedis.RedisContainer
Client *redis.Client
}
RedisFeature is a struct containing a testcontainer redis database
func NewRedisFeature ¶ added in v0.21.0
func NewRedisFeature(opts RedisOptions) *RedisFeature
NewRedisFeature creates a new testcontainer redis database using the supplied options
func (*RedisFeature) Close ¶ added in v0.21.0
func (r *RedisFeature) Close() error
Close stops the testcontainer redis
func (*RedisFeature) RegisterSteps ¶ added in v0.21.0
func (r *RedisFeature) RegisterSteps(ctx *godog.ScenarioContext)
func (*RedisFeature) Reset ¶ added in v0.21.0
func (r *RedisFeature) Reset() error
Reset drops all keys from the testcontainer redis
type RedisOptions ¶
type RedisOptions struct {
RedisVersion string
}
type ServiceInitialiser ¶
func StaticHandler ¶
func StaticHandler(handler http.Handler) ServiceInitialiser
type UIFeature ¶ added in v0.6.5
type UIFeature struct {
ErrorFeature
BaseURL string
Chrome Chrome
WaitTimeOut time.Duration
}
UIFeature contains the information needed to test UI interactions
func NewUIFeature ¶ added in v0.6.5
NewUIFeature returns a new UIFeature configured with baseURL
func (*UIFeature) CheckLocationUntilTimeOut ¶ added in v0.19.0
func (*UIFeature) RegisterSteps ¶ added in v0.6.5
func (f *UIFeature) RegisterSteps(ctx *godog.ScenarioContext)
RegisterSteps binds the APIFeature steps to the godog context to enable usage in the component tests
func (*UIFeature) RunWithTimeOut ¶ added in v0.7.0
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
api
command
|
|
|
api_with_mongo
command
|
|
|
api_with_redis
command
|
|
|
authorized_api
command
|
|
|
event_driven_with_kafka
command
|
|
|
ui
command
|
|
|
revive:disable:var-naming
|
revive:disable:var-naming |