Documentation
¶
Index ¶
- func AssertErrorResponse(t *testing.T, rec *httptest.ResponseRecorder, expectedStatus int, ...)
- func AssertHeader(t *testing.T, rec *httptest.ResponseRecorder, header, expectedValue string)
- func AssertHeaderExists(t *testing.T, rec *httptest.ResponseRecorder, header string)
- func AssertJSONResponse(t *testing.T, rec *httptest.ResponseRecorder, target any)
- func AssertResponseBody(t *testing.T, rec *httptest.ResponseRecorder, expected string)
- func AssertResponseContains(t *testing.T, rec *httptest.ResponseRecorder, substring string)
- func AssertStatusCode(t *testing.T, rec *httptest.ResponseRecorder, expectedStatus int)
- func AssertSuccessResponse(t *testing.T, rec *httptest.ResponseRecorder)
- func CleanupDatabase(t *testing.T, ctx context.Context, pg *gfrpostgres.Postgres)
- func CleanupFunc(t *testing.T, fn func())
- func Context(t *testing.T) context.Context
- func ContextWithCustomTimeout(t *testing.T, timeout time.Duration) (context.Context, context.CancelFunc)
- func ContextWithDeadline(t *testing.T, deadline time.Time) (context.Context, context.CancelFunc)
- func ContextWithTimeout(t *testing.T) (context.Context, context.CancelFunc)
- func Eventually(t *testing.T, condition func() bool, timeout time.Duration, ...)
- func EventuallyWithMessage(t *testing.T, condition func() bool, timeout time.Duration, ...)
- func MustParseJSONResponse(t *testing.T, rec *httptest.ResponseRecorder, target interface{})
- func Parallel(t *testing.T)
- func ParseJSONResponse(rec *httptest.ResponseRecorder, target interface{}) error
- func RandomEmail() string
- func RandomInt(minVal, maxVal int64) int64
- func RandomString(length int) string
- func RequireEnv(t *testing.T, key string) string
- func RunMigrations(ctx context.Context, pool *gfrpostgres.Postgres, migrationPath string) error
- func SetupEchoContext(t *testing.T, opts *Options) (*echo.Context, *httptest.ResponseRecorder, *http.Request)
- func SetupEchoContextWithAuth(t *testing.T, opts *Options, token string) (*echo.Context, *httptest.ResponseRecorder, *http.Request)
- func SetupEchoContextWithJSON(t *testing.T, method string, path string, body interface{}) (*echo.Context, *httptest.ResponseRecorder, *http.Request)
- func SkipIfShort(t *testing.T)
- type Options
- type PostgresTestContainer
- type ValkeyTestContainer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertErrorResponse ¶
func AssertHeader ¶
func AssertHeader(t *testing.T, rec *httptest.ResponseRecorder, header, expectedValue string)
func AssertHeaderExists ¶
func AssertHeaderExists(t *testing.T, rec *httptest.ResponseRecorder, header string)
func AssertJSONResponse ¶
func AssertJSONResponse(t *testing.T, rec *httptest.ResponseRecorder, target any)
func AssertResponseBody ¶
func AssertResponseBody(t *testing.T, rec *httptest.ResponseRecorder, expected string)
func AssertResponseContains ¶
func AssertResponseContains(t *testing.T, rec *httptest.ResponseRecorder, substring string)
func AssertStatusCode ¶
func AssertStatusCode(t *testing.T, rec *httptest.ResponseRecorder, expectedStatus int)
func AssertSuccessResponse ¶
func AssertSuccessResponse(t *testing.T, rec *httptest.ResponseRecorder)
func CleanupDatabase ¶
func CleanupFunc ¶
func ContextWithDeadline ¶
func ContextWithTimeout ¶
func Eventually ¶
func EventuallyWithMessage ¶
func MustParseJSONResponse ¶
func MustParseJSONResponse(t *testing.T, rec *httptest.ResponseRecorder, target interface{})
func ParseJSONResponse ¶
func ParseJSONResponse(rec *httptest.ResponseRecorder, target interface{}) error
func RandomEmail ¶
func RandomEmail() string
func RandomString ¶
func RunMigrations ¶
func SetupEchoContext ¶
func SkipIfShort ¶
Types ¶
type Options ¶
type Options struct {
Method string // HTTP method (GET, POST, etc.)
Path string // Request path
Body []byte // Request body
Headers map[string]string // Custom headers
QueryParams map[string]string // Query parameters
PathParams map[string]string // Path parameters (e.g., :id)
ContentType string // Content-Type header (defaults to application/json)
SkipRequestID bool // Skip auto-generating X-Request-ID header
}
type PostgresTestContainer ¶
type PostgresTestContainer struct {
Container testcontainers.Container
User string
Password string
Host string
Database string
Port nat.Port
}
func SetupPostgresContainer ¶
func SetupPostgresContainer(t *testing.T) *PostgresTestContainer
func (*PostgresTestContainer) ConnectionString ¶
func (c *PostgresTestContainer) ConnectionString() string
func (*PostgresTestContainer) DSN ¶
func (c *PostgresTestContainer) DSN() string
type ValkeyTestContainer ¶
type ValkeyTestContainer struct {
Container testcontainers.Container
Host string
Port nat.Port
}
func SetupValkeyContainer ¶
func SetupValkeyContainer(t *testing.T) *ValkeyTestContainer
func (*ValkeyTestContainer) Address ¶
func (c *ValkeyTestContainer) Address() string
Click to show internal directories.
Click to hide internal directories.