Documentation
¶
Index ¶
- Variables
- func AdvisoryLocks(t *testing.T, tx pgx.Tx) int
- func Begin(t *testing.T, pool *pgxpool.Pool) pgx.Tx
- func Claims() auth.Claims
- func EncodedKey(key []byte) []byte
- func HTTPModule(t *testing.T, opts []modules.Option) *httpModule.Module
- func InsertItem(ctx context.Context, db execer, subscriberID uuid.UUID) error
- func InsertItems(t *testing.T, pool *pgxpool.Pool, subscriberID uuid.UUID, n int)
- func ItemCount(t *testing.T, pool *pgxpool.Pool, subscriberID uuid.UUID) int
- func NoContent(c *gin.Context)
- func Postgres(t *testing.T) *pgxpool.Pool
- func Request(t *testing.T, handler http.Handler, method, path string, ...) int
- func SaveConcurrently(t *testing.T, pool *pgxpool.Pool, n int, ...) []error
- func SignToken(t *testing.T, method jwt.SigningMethod, claims auth.Claims, key any) string
- func TraefikRouterMiddlewares(t *testing.T, path string) map[string][]string
- func UserToken(t *testing.T, claims auth.Claims) string
- func Validator(t *testing.T) *auth.Validator
- type ItemCounter
- type Result
Constants ¶
This section is empty.
Variables ¶
var ( UserTokenKey = []byte("0123456789abcdef0123456789abcdef") OtherUserTokenKey = []byte("fedcba9876543210fedcba9876543210") )
Functions ¶
func AdvisoryLocks ¶ added in v0.23.0
AdvisoryLocks returns how many advisory locks tx's connection holds.
func Begin ¶ added in v0.23.0
Begin begins a transaction that is rolled back when the test ends, unless it was committed.
func EncodedKey ¶
func HTTPModule ¶
HTTPModule configures a bootstrapify http module with opts and registers ErrorResponse, the way a service does before defining its routes.
func InsertItem ¶ added in v0.23.0
InsertItem inserts one item of the subscriber on db, a pool or a tx.
func InsertItems ¶ added in v0.23.0
func Postgres ¶ added in v0.23.0
Postgres returns a pool on TEST_DATABASE_DSN whose search_path is a schema of the test's own, holding an items(subscriber_id) table. The schema is dropped when the test ends. It skips without the DSN, and fails without it in CI.
func Request ¶
func Request(t *testing.T, handler http.Handler, method, path string, headers map[string]string) int
Request sends a request with the headers to the handler and returns the response status.
func SaveConcurrently ¶ added in v0.23.0
func SaveConcurrently( t *testing.T, pool *pgxpool.Pool, n int, save func(ctx context.Context, tx pgx.Tx) error, ) []error
SaveConcurrently begins n transactions, then runs save on all of them at once and commits each one save returned nil for. It returns each save's error, or the error of beginning or committing its transaction.
func TraefikRouterMiddlewares ¶
TraefikRouterMiddlewares reads an exported Traefik routes file and returns the middlewares of each router, by router name.
Types ¶
type ItemCounter ¶ added in v0.23.0
type ItemCounter struct {
Calls int
// contains filtered or unexported fields
}
ItemCounter counts a subscriber's items on a tx, the way a consumer's tx-bound repository does, and records how often it was called.
func CountItems ¶ added in v0.23.0
func CountItems(tx pgx.Tx, subscriberID uuid.UUID) *ItemCounter
type Result ¶
type Result struct {
Status int
Error *response.ErrorResponse
IsReached bool
Context context.Context
}
Result is what a request served by Serve produced. Context is the request context the handler saw, nil when the handler was not reached.