test

package
v0.0.0-...-d0162ed Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateConnection

func CreateConnection(ctx context.Context, db *dbcontext.DB, id int) error

CreateConnection creates a connection.

func CreateRequest

func CreateRequest(ctx context.Context, db *dbcontext.DB, id string, connectionID int) error

func DB

func DB(t *testing.T) *dbcontext.DB

DB returns the database connection for testing purpose.

func Endpoint

func Endpoint(t *testing.T, router *echo.Echo, tc APITestCase)

Endpoint tests an HTTP endpoint using the given APITestCase spec.

func MockRouter

func MockRouter(logger log.Logger) *echo.Echo

MockRouter creates a routing.Router for testing APIs.

func MockRoutingContext

func MockRoutingContext(req *http.Request) (echo.Context, *httptest.ResponseRecorder)

MockRoutingContext creates a routing.Conext for testing handlers.

func ResetTables

func ResetTables(t *testing.T, db *dbcontext.DB, tables ...string)

ResetTables truncates all data in the specified tables.

Types

type APITestCase

type APITestCase struct {
	Name         string
	Method, URL  string
	Body         string
	Header       http.Header
	WantStatus   int
	WantResponse string
}

APITestCase represents the data needed to describe an API test case.

Jump to

Keyboard shortcuts

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