steps

package
v0.16.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2022 License: MIT Imports: 34 Imported by: 0

Documentation

Overview

Package steps is used to define the steps that are used in the component test, which is written in godog (Go's version of cucumber).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorFeature added in v0.14.0

type ErrorFeature struct {
	testing.TB
	// contains filtered or unexported fields
}

func (*ErrorFeature) Errorf added in v0.14.0

func (t *ErrorFeature) Errorf(format string, args ...interface{})

func (*ErrorFeature) Helper added in v0.14.0

func (t *ErrorFeature) Helper()

func (*ErrorFeature) Log added in v0.14.0

func (t *ErrorFeature) Log(args ...interface{})

func (*ErrorFeature) Logf added in v0.14.0

func (t *ErrorFeature) Logf(format string, args ...interface{})

func (*ErrorFeature) Name added in v0.14.0

func (t *ErrorFeature) Name() string

func (*ErrorFeature) StepError added in v0.14.0

func (t *ErrorFeature) StepError() error

type JobsFeature

type JobsFeature struct {
	ErrorFeature componentTest.ErrorFeature

	Config         *config.Config
	HTTPServer     *http.Server
	ServiceRunning bool
	APIFeature     *componentTest.APIFeature

	MongoClient     *mongo.JobStore
	MongoFeature    *componentTest.MongoFeature
	AuthFeature     *componentTest.AuthorizationFeature
	SearchFeature   *SearchFeature
	KafkaProducer   service.KafkaProducer
	MessageProducer kafka.IProducer
	// contains filtered or unexported fields
}

JobsFeature is a type that contains all the requirements for running a godog (cucumber) feature that tests the /jobs endpoint.

func NewJobsFeature

func NewJobsFeature(mongoFeature *componentTest.MongoFeature,
	authFeature *componentTest.AuthorizationFeature,
	searchFeature *SearchFeature) (*JobsFeature, error)

NewJobsFeature returns a pointer to a new JobsFeature, which can then be used for testing the /jobs endpoint.

func (*JobsFeature) Close

func (f *JobsFeature) Close() error

Close stops the *service.Service, which is pointed to from within the specific JobsFeature, from running.

func (*JobsFeature) DoGetAuthorisationHandlers added in v0.9.0

func (f *JobsFeature) DoGetAuthorisationHandlers(ctx context.Context, cfg *config.Config) api.AuthHandler

DoGetAuthorisationHandlers returns the mock AuthHandler that was created in the NewJobsFeature function.

func (*JobsFeature) DoGetHTTPServer

func (f *JobsFeature) DoGetHTTPServer(bindAddr string, router http.Handler) service.HTTPServer

DoGetHTTPServer takes a bind Address (string) and a router (http.Handler), which are used to set up an HTTPServer. The HTTPServer is in a specific JobsFeature and is returned.

func (*JobsFeature) DoGetHealthcheckOk

func (f *JobsFeature) DoGetHealthcheckOk(cfg *config.Config, curTime, commit, version string) (service.HealthChecker, error)

DoGetHealthcheckOk returns a mock HealthChecker service for a specific JobsFeature.

func (*JobsFeature) DoGetKafkaProducer added in v0.15.0

func (f *JobsFeature) DoGetKafkaProducer(ctx context.Context, cfg *config.Config) (service.KafkaProducer, error)

DoGetKafkaProducer returns a mock kafka producer.

func (*JobsFeature) DoGetMongoDB added in v0.5.0

func (f *JobsFeature) DoGetMongoDB(ctx context.Context, cfg *config.Config) (service.MongoDataStorer, error)

DoGetMongoDB returns a MongoDB, for the component test, which has a random database name and different URI to the one used by the API under test.

func (*JobsFeature) GetJobByID added in v0.7.0

func (f *JobsFeature) GetJobByID(id string) error

GetJobByID is a utility function that is used for calling the GET /jobs/{id} endpoint. It checks that the id string is a valid UUID before calling the endpoint.

func (*JobsFeature) GetTaskForJob added in v0.10.0

func (f *JobsFeature) GetTaskForJob(jobID, taskName string) error

GetTaskForJob is a utility function that is used for calling GET /jobs/{id}/tasks/{task name}

func (*JobsFeature) InitAPIFeature

func (f *JobsFeature) InitAPIFeature() *componentTest.APIFeature

InitAPIFeature initialises the APIFeature that's contained within a specific JobsFeature.

func (*JobsFeature) InitialiseService

func (f *JobsFeature) InitialiseService() (http.Handler, error)

InitialiseService returns the http.Handler that's contained within a specific JobsFeature.

func (*JobsFeature) PostTaskForJob added in v0.9.0

func (f *JobsFeature) PostTaskForJob(jobID string, requestBody *godog.DocString) error

PostTaskForJob is a utility function that is used for calling POST /jobs/{id}/tasks The endpoint requires authorisation and a request body.

func (*JobsFeature) PutNumberOfTasks added in v0.7.0

func (f *JobsFeature) PutNumberOfTasks(countStr string) error

PutNumberOfTasks is a utility function that is used for calling the PUT /jobs/{id}/number_of_tasks/{count} It checks that the id string is a valid UUID before calling the endpoint.

func (*JobsFeature) RegisterSteps

func (f *JobsFeature) RegisterSteps(ctx *godog.ScenarioContext)

RegisterSteps defines the steps within a specific JobsFeature cucumber test.

func (*JobsFeature) Reset

func (f *JobsFeature) Reset(mongoFail bool) error

Reset sets the resources within a specific JobsFeature back to their default values.

type SearchFeature added in v0.14.0

type SearchFeature struct {
	ErrorFeature
	FakeSearchAPI *httpfake.HTTPFake
}

func NewSearchFeature added in v0.14.0

func NewSearchFeature() *SearchFeature

func (*SearchFeature) Close added in v0.14.0

func (f *SearchFeature) Close()

func (*SearchFeature) RegisterSteps added in v0.14.0

func (f *SearchFeature) RegisterSteps(ctx *godog.ScenarioContext)

RegisterSteps defines the steps within a specific SearchFeature cucumber test.

func (*SearchFeature) Reset added in v0.14.0

func (f *SearchFeature) Reset()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL