test

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2020 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 *routing.Router, tc APITestCase)

Endpoint tests an HTTP endpoint using the given APITestCase spec.

func MockRouter

func MockRouter(logger log.Logger) *routing.Router

MockRouter creates a routing.Router for testing APIs.

func MockRoutingContext

func MockRoutingContext(req *http.Request) (*routing.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