servicetest

package
v2.24.2 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package servicetest provides utilities to test services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetResponseForRouteWithMockedDBAndUser

func GetResponseForRouteWithMockedDBAndUser(
	method, path, requestBody string, user *database.User,
	setMockExpectationsFunc func(sqlmock.Sqlmock),
	setRouterFunc func(router *chi.Mux, baseService *service.Base),
) (*http.Response, sqlmock.Sqlmock, string, error)

GetResponseForRouteWithMockedDBAndUser executes a route for unit tests auth.UserIDFromContext is stubbed to return the given userID. The test should provide functions that prepare the router and the sql mock.

func WithLoggingMiddleware

func WithLoggingMiddleware(appHandler http.Handler) (http.Handler, *loggingtest.Hook, func())

WithLoggingMiddleware wraps the given handler in NullLogger with hook.

Types

This section is empty.

Jump to

Keyboard shortcuts

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