testutil

package
v0.0.0-...-a131ce6 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2023 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreatePostgresTestContainer

func CreatePostgresTestContainer(ctx context.Context, dbname string) (testcontainers.Container, *sql.DB, error)

func GetCallerPath

func GetCallerPath() string

func NewFakeUser

func NewFakeUser(t *testing.T, name, email, password string, activated bool) *domain.User

NewFakeUser creates a new fake user for testing perpose.

func NewPgMigrator

func NewPgMigrator(db *sql.DB) (*migrate.Migrate, error)

func NewTestDB

func NewTestDB(t *testing.T) *sql.DB

func PrepareSQLQuery

func PrepareSQLQuery(t *testing.T, db *sql.DB, filepath string) func(t *testing.T)

filepath should based on filepath from the project working directory: todos/.

func TestEndpoint

func TestEndpoint(t *testing.T, router *httprouter.Router, tc APITestCase)

Endpoint tests an HTTP endpoint using the given APITestCase spec.

Types

type APITestCase

type APITestCase struct {
	Name        string
	Method, URL string
	Body        string
	Header      http.Header
	WantStatus  int
	WantBody    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