Documentation
¶
Index ¶
- Variables
- func CreateTestDBName(conf config.Config) string
- func GetTestLogger(tb testing.TB) log.Logger
- func IntegrationTest(t *testing.T)
- func NewContext(dbGORM databasegorm.DB, dbBun *bun.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 NewMockAuthNGin(t *testing.T, principal middleware_gin.Principal) fx.Option
- func NewTestConfig(rootConf config.RootConfig) config.Config
- func NewTestDBBun(conf config.Config, lf log.LoggerFactory) *bun.DB
- func NewTestDBGORM(conf config.Config, lf log.LoggerFactory) database.DB
- func NewTestDynamoDB(_ testing.TB, ctx context.Context, conf config.Config, ...) *dynamodb.DynamoDB
- func NewTestHTTPHandlerGin(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 OnTestDBBunStop(ctx context.Context, conf config.Config, db *bun.DB, lf log.LoggerFactory) error
- func OnTestDBGORMStop(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 AcceptType
- type BodyType
- type FxApp
- func (a *FxApp) Populate(targets ...any) *FxApp
- func (a *FxApp) Stop()
- func (a *FxApp) Wait() <-chan fx.ShutdownSignal
- func (a *FxApp) WithDBBun() *FxApp
- func (a *FxApp) WithDBGORM() *FxApp
- func (a *FxApp) WithHTTPHandler() *FxApp
- func (a *FxApp) WithHTTPHandlerGin() *FxApp
- func (a *FxApp) WithRedis() *FxApp
- func (a *FxApp) WithWorkerHandler() *FxApp
- type HTTPHandlerClient
- func (c *HTTPHandlerClient) DELETE(req RequestArgs, urlArgs ...any) *Response
- func (c *HTTPHandlerClient) Do(method string, reqArgs RequestArgs, urlArgs ...any) *Response
- func (c *HTTPHandlerClient) GET(req RequestArgs, urlArgs ...any) *Response
- func (c *HTTPHandlerClient) PATCH(req RequestArgs, urlArgs ...any) *Response
- func (c *HTTPHandlerClient) POST(req RequestArgs, urlArgs ...any) *Response
- func (c *HTTPHandlerClient) PUT(req RequestArgs, urlArgs ...any) *Response
- func (c *HTTPHandlerClient) SetHeaders(headers http.Header) *HTTPHandlerClient
- type HTTPHandlerClientGin
- func (c *HTTPHandlerClientGin) DELETE(urlFormat string, args ...any) *ResponseGin
- func (c *HTTPHandlerClientGin) Do(method, url string, body any) *ResponseGin
- func (c *HTTPHandlerClientGin) GET(urlFormat string, args ...any) *ResponseGin
- func (c *HTTPHandlerClientGin) PATCH(body any, urlFormat string, args ...any) *ResponseGin
- func (c *HTTPHandlerClientGin) POST(body any, urlFormat string, args ...any) *ResponseGin
- func (c *HTTPHandlerClientGin) SetHeaders(headers http.Header) *HTTPHandlerClientGin
- type RequestArgs
- type Response
- func (r *Response) Body() io.ReadCloser
- func (r *Response) BodyBytes() []byte
- func (r *Response) BodyString() string
- func (r *Response) RequireEmptyBody()
- func (r *Response) RequireHeader(header, value string)
- func (r *Response) RequireJSONBodyAs(target any)
- func (r *Response) RequireStatus(status int)
- func (r *Response) StatusCode() int
- type ResponseGin
- type Target
- type TargetBase
Constants ¶
This section is empty.
Variables ¶
View Source
var FxExportContext = fx.Provide(fx.Annotate(NewContext, fx.ParamTags(`optional:"true"`, `optional:"true"`)))
View Source
var FxExportMiddlewaresGin = fx.Options( fx.Invoke(middleware_gin.NewMiddlewares), middleware_gin.RequestLoggerModule, middleware_gin.ProvideAsMiddleware(middleware_gin.NewPanicRecovery), middleware_gin.ProvideAsMiddleware(middleware_gin.NewErrorHandlerFx), )
View Source
var FxExportRedis = fx.Provide( fx.Annotate( NewTestRedis, fx.OnStop(OnTestRedisStop), ), )
View Source
var FxExportRest = fx.Options( middleware.FxExport, fx.Provide(rest.NewResources), fx.Provide(rest.NewStdServer), )
View Source
var FxExportRestGin = fx.Options( fx.Provide(NewTestHTTPHandlerGin), fx.Invoke(rest_gin.NewResources), )
View Source
var FxExportTestAWSLocalStackConfig = fx.Options( fx.Provide(NewLocalStackAWSConfig), )
View Source
var FxExportTestConfig = fx.Options( fx.Provide(NewTestConfig), fx.Provide(NewTestRootConfig), )
View Source
var FxExportTestDynamoDB = fx.Options( fx.Provide(dynamodb.NewAWSDynamoDBClient), fx.Provide(fx.Annotate( NewTestDynamoDB, fx.OnStop(OnTestDynamoDBStop), )), )
View Source
var TestFxExportDBBun = di.FxProvideAs[bun.IDB](NewTestDBBun, []fx.Annotation{fx.OnStop(OnTestDBBunStop)}, nil)
View Source
var TestFxExportDBGORM = fx.Provide( fx.Annotate( NewTestDBGORM, fx.OnStop(OnTestDBGORMStop), ), )
View Source
var TestModuleWorkerHandler = worker.FxExport
Functions ¶
func CreateTestDBName ¶
func IntegrationTest ¶
IntegrationTest will skip if this is a testing.Short test run
func NewContext ¶
func NewContext(dbGORM databasegorm.DB, dbBun *bun.DB, lf log.LoggerFactory) context.Context
func NewLocalStackAWSConfig ¶ added in v0.5.0
func NewLoggerFactory ¶
func NewLoggerFactory(tb testing.TB, conf config.RootConfig) log.LoggerFactory
func NewMockAuthNGin ¶ added in v0.7.0
func NewTestConfig ¶ added in v0.5.0
func NewTestConfig(rootConf config.RootConfig) config.Config
func NewTestDBBun ¶ added in v0.7.0
func NewTestDBGORM ¶ added in v0.7.0
func NewTestDynamoDB ¶ added in v0.5.0
func NewTestHTTPHandlerGin ¶ added in v0.7.0
func NewTestHTTPHandlerGin(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 OnTestDBBunStop ¶ added in v0.7.0
func OnTestDBGORMStop ¶ added in v0.7.0
func OnTestDynamoDBStop ¶ added in v0.5.0
func OnTestRedisStop ¶
Types ¶
type AcceptType ¶ added in v0.7.0
type AcceptType string
const ( AcceptTypeJSON AcceptType = "json" AcceptTypeYAML AcceptType = "yaml" AcceptTypeBinary AcceptType = "binary" AcceptTypeText AcceptType = "text" AcceptTypeSSE AcceptType = "sse" )
type FxApp ¶
type FxApp struct {
// contains filtered or unexported fields
}
func FxIntegrationWithDBBun ¶ added in v0.7.0
func FxIntegrationWithDBGORM ¶ added in v0.7.0
func (*FxApp) Wait ¶
func (a *FxApp) Wait() <-chan fx.ShutdownSignal
func (*FxApp) WithDBGORM ¶ added in v0.7.0
func (*FxApp) WithHTTPHandler ¶
func (*FxApp) WithHTTPHandlerGin ¶ added in v0.7.0
func (*FxApp) WithWorkerHandler ¶
type HTTPHandlerClient ¶
type HTTPHandlerClient struct {
// contains filtered or unexported fields
}
HTTPHandlerClient is a client for testing HTTPHandler implementations.
func NewHTTPClient ¶
func (*HTTPHandlerClient) DELETE ¶
func (c *HTTPHandlerClient) DELETE(req RequestArgs, urlArgs ...any) *Response
func (*HTTPHandlerClient) Do ¶
func (c *HTTPHandlerClient) Do(method string, reqArgs RequestArgs, urlArgs ...any) *Response
func (*HTTPHandlerClient) GET ¶
func (c *HTTPHandlerClient) GET(req RequestArgs, urlArgs ...any) *Response
func (*HTTPHandlerClient) PATCH ¶
func (c *HTTPHandlerClient) PATCH(req RequestArgs, urlArgs ...any) *Response
func (*HTTPHandlerClient) POST ¶
func (c *HTTPHandlerClient) POST(req RequestArgs, urlArgs ...any) *Response
func (*HTTPHandlerClient) PUT ¶ added in v0.7.0
func (c *HTTPHandlerClient) PUT(req RequestArgs, urlArgs ...any) *Response
func (*HTTPHandlerClient) SetHeaders ¶
func (c *HTTPHandlerClient) SetHeaders(headers http.Header) *HTTPHandlerClient
type HTTPHandlerClientGin ¶ added in v0.7.0
type HTTPHandlerClientGin struct {
// contains filtered or unexported fields
}
HTTPHandlerClientGin is a client for testing HTTPHandler implementations.
func NewHTTPClientGin ¶ added in v0.7.0
func NewHTTPClientGin(t *testing.T, httpHandler rest.HTTPHandler) *HTTPHandlerClientGin
func (*HTTPHandlerClientGin) DELETE ¶ added in v0.7.0
func (c *HTTPHandlerClientGin) DELETE( urlFormat string, args ...any, ) *ResponseGin
func (*HTTPHandlerClientGin) Do ¶ added in v0.7.0
func (c *HTTPHandlerClientGin) Do(method, url string, body any) *ResponseGin
func (*HTTPHandlerClientGin) GET ¶ added in v0.7.0
func (c *HTTPHandlerClientGin) GET( urlFormat string, args ...any, ) *ResponseGin
func (*HTTPHandlerClientGin) PATCH ¶ added in v0.7.0
func (c *HTTPHandlerClientGin) PATCH( body any, urlFormat string, args ...any, ) *ResponseGin
func (*HTTPHandlerClientGin) POST ¶ added in v0.7.0
func (c *HTTPHandlerClientGin) POST( body any, urlFormat string, args ...any, ) *ResponseGin
func (*HTTPHandlerClientGin) SetHeaders ¶ added in v0.7.0
func (c *HTTPHandlerClientGin) SetHeaders(headers http.Header) *HTTPHandlerClientGin
type RequestArgs ¶ added in v0.7.0
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
func (*Response) Body ¶ added in v0.7.0
func (r *Response) Body() io.ReadCloser
func (*Response) BodyString ¶ added in v0.7.0
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 ¶
func (*Response) StatusCode ¶ added in v0.7.0
type ResponseGin ¶ added in v0.7.0
type ResponseGin struct {
// contains filtered or unexported fields
}
func (*ResponseGin) RequireEmptyBody ¶ added in v0.7.0
func (r *ResponseGin) RequireEmptyBody() *ResponseGin
func (*ResponseGin) RequireHeader ¶ added in v0.7.0
func (r *ResponseGin) RequireHeader(header, value string) *ResponseGin
func (*ResponseGin) RequireJSONBodyAs ¶ added in v0.7.0
func (r *ResponseGin) RequireJSONBodyAs(target any)
RequireJSONBodyAs decodes the response body as JSON into the given body. Target must be a reference to store the deserialized body.
func (*ResponseGin) RequireStatus ¶ added in v0.7.0
func (r *ResponseGin) RequireStatus(status int) *ResponseGin
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.