Documentation
¶
Index ¶
- Variables
- func CreateTestDBName(conf config.Config) string
- func GetTestLogger(tb testing.TB) log.Logger
- func IntegrationTest(t *testing.T)
- func NewContext(db database.DB, lf *log.LoggerFactory) context.Context
- func NewLocalStackAWSConfig(tb testing.TB) (aws.Config, error)
- func NewLoggerFactory(tb testing.TB, conf config.RootConfig) *log.LoggerFactory
- func NewMockAuthN(t *testing.T, principal middleware.Principal) fx.Option
- func NewTestConfig(rootConf config.RootConfig) config.Config
- func NewTestDatabase(conf config.Config, lf *log.LoggerFactory) database.DB
- func NewTestDynamoDB(_ testing.TB, ctx context.Context, conf config.Config, ...) *dynamodb.DynamoDB
- func NewTestHTTPHandler(conf config.Config, lf *log.LoggerFactory) rest.HTTPHandler
- func NewTestRedis(conf config.Config, lf *log.LoggerFactory) redis.Redis
- func NewTestRootConfig(tb testing.TB) config.RootConfig
- func OnTestDBStop(conf config.Config, db database.DB, lf *log.LoggerFactory) error
- func OnTestDynamoDBStop(tb testing.TB, ctx context.Context, ddb *dynamodb.DynamoDB) error
- func OnTestRedisStop(redis redis.Redis) error
- type FxApp
- type HTTPHandlerClient
- func (c *HTTPHandlerClient) DELETE(urlFormat string, args ...any) *Response
- func (c *HTTPHandlerClient) Do(method, url string, body any) *Response
- func (c *HTTPHandlerClient) GET(urlFormat string, args ...any) *Response
- func (c *HTTPHandlerClient) PATCH(body any, urlFormat string, args ...any) *Response
- func (c *HTTPHandlerClient) POST(body any, urlFormat string, args ...any) *Response
- func (c *HTTPHandlerClient) SetHeaders(headers http.Header) *HTTPHandlerClient
- type Response
- type Target
- type TargetBase
Constants ¶
This section is empty.
Variables ¶
View Source
var ModuleContext = fx.Provide(fx.Annotate(NewContext, fx.ParamTags(`optional:"true"`)))
View Source
var ModuleMiddlewares = fx.Options( fx.Invoke(middleware.NewMiddlewares), middleware.RequestLoggerModule, middleware.ProvideAsMiddleware(middleware.NewPanicRecovery), middleware.ProvideAsMiddleware(middleware.NewErrorHandlerFx), )
View Source
var ModuleRedis = fx.Provide( fx.Annotate( NewTestRedis, fx.OnStop(OnTestRedisStop), ), )
View Source
var ModuleTestAWSLocalStackConfig = fx.Options( fx.Provide(NewLocalStackAWSConfig), )
View Source
var ModuleTestConfig = fx.Options( fx.Provide(NewTestConfig), fx.Provide(NewTestRootConfig), )
View Source
var ModuleTestDynamoDB = fx.Options( fx.Provide(dynamodb.NewAWSDynamoDBClient), fx.Provide(fx.Annotate( NewTestDynamoDB, fx.OnStop(OnTestDynamoDBStop), )), )
View Source
var TestModuleDB = fx.Provide( fx.Annotate( NewTestDatabase, fx.OnStop(OnTestDBStop), ), )
View Source
var TestModuleHTTPHandler = fx.Provide(NewTestHTTPHandler)
View Source
var TestModuleRest = rest.Module
View Source
var TestModuleWorkerHandler = worker.ModuleWorkerHandler
Functions ¶
func CreateTestDBName ¶
func IntegrationTest ¶
IntegrationTest will skip if this is a testing.Short test run
func NewContext ¶
func NewLocalStackAWSConfig ¶ added in v0.5.0
func NewLoggerFactory ¶
func NewLoggerFactory(tb testing.TB, conf config.RootConfig) *log.LoggerFactory
func NewMockAuthN ¶
func NewTestConfig ¶ added in v0.5.0
func NewTestConfig(rootConf config.RootConfig) config.Config
func NewTestDatabase ¶
func NewTestDynamoDB ¶ added in v0.5.0
func NewTestHTTPHandler ¶
func NewTestHTTPHandler(conf config.Config, lf *log.LoggerFactory) rest.HTTPHandler
func NewTestRedis ¶
func NewTestRootConfig ¶ added in v0.5.0
func NewTestRootConfig(tb testing.TB) config.RootConfig
func OnTestDBStop ¶
func OnTestDynamoDBStop ¶ added in v0.5.0
func OnTestRedisStop ¶
Types ¶
type FxApp ¶
type FxApp struct {
// contains filtered or unexported fields
}
func FxIntegrationWithDB ¶
FxIntegrationWithDB is a helper function to create an integration test with DB
func (*FxApp) Wait ¶
func (a *FxApp) Wait() <-chan fx.ShutdownSignal
func (*FxApp) WithHTTPHandler ¶
func (*FxApp) WithWorkerHandler ¶
type HTTPHandlerClient ¶
type HTTPHandlerClient struct {
// contains filtered or unexported fields
}
HTTPHandlerClient is a client for testing HTTPHandler implementations.
func NewHTTPClient ¶
func NewHTTPClient(t *testing.T, httpHandler rest.HTTPHandler) *HTTPHandlerClient
func (*HTTPHandlerClient) DELETE ¶
func (c *HTTPHandlerClient) DELETE( urlFormat string, args ...any, ) *Response
func (*HTTPHandlerClient) Do ¶
func (c *HTTPHandlerClient) Do(method, url string, body any) *Response
func (*HTTPHandlerClient) GET ¶
func (c *HTTPHandlerClient) GET( urlFormat string, args ...any, ) *Response
func (*HTTPHandlerClient) PATCH ¶
func (c *HTTPHandlerClient) PATCH( body any, urlFormat string, args ...any, ) *Response
func (*HTTPHandlerClient) POST ¶
func (c *HTTPHandlerClient) POST( body any, urlFormat string, args ...any, ) *Response
func (*HTTPHandlerClient) SetHeaders ¶
func (c *HTTPHandlerClient) SetHeaders(headers http.Header) *HTTPHandlerClient
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
func (*Response) RequireEmptyBody ¶
func (r *Response) RequireEmptyBody()
func (*Response) RequireHeader ¶
func (*Response) RequireJSONBodyAs ¶
RequireJSONBodyAs decodes the response body as JSON into the given body. Target must be a reference to store the deserialized body.
func (*Response) RequireStatus ¶
type Target ¶
type Target interface {
GetBase() TargetBase
}
type TargetBase ¶
type TargetBase struct { fx.In Ctx context.Context Conf config.Config DB database.DB `optional:"true"` Redis redis.Redis `optional:"true"` HTTPHandler rest.HTTPHandler `optional:"true"` }
func (TargetBase) GetBase ¶
func (f TargetBase) GetBase() TargetBase
Click to show internal directories.
Click to hide internal directories.