testserver

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func PostgresConnect

func PostgresConnect(t *testing.T, allowPurge bool) *sqlx.DB

func StartPostgresAndMigrate

func StartPostgresAndMigrate() (*sqlx.DB, *dockertest.Pool, *dockertest.Resource)
Example
package main

import (
	"fmt"

	"github.com/rsachdeva/illuminatingdeposits-rest/testserver"
	"github.com/rsachdeva/illuminatingdeposits-rest/tools/dbcli/schema"
)

func main() {
	db, pool, resource := testserver.StartPostgresAndMigrate()
	// this is just for this test to make sure can populate db; we don't require this for tests in general
	err := schema.Seed(db)
	if err != nil {
		fmt.Println("Cound not seed test database")
	}
	err = pool.Purge(resource)
	fmt.Println("ExamplePostgresConnect err is", err)
}
Output:

ExamplePostgresConnect err is <nil>

Types

type ClientResult

type ClientResult struct {
	URL            string
	TestClient     *http.Client
	PostgresClient *sqlx.DB
}

func InitRestHttpTLS

func InitRestHttpTLS(t *testing.T, allowPurge bool) ClientResult

Jump to

Keyboard shortcuts

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