tests

package
v0.0.0-...-bd5dacb Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserUsername = "test@test.com"
	UserPassword = "00000000"
)

Variables

This section is empty.

Functions

func Execute

func Execute(t *testing.T, db *db.DB, tests []Test, templatesPath string)

Execute runs all tests.

func JsonToString

func JsonToString(d interface{}) string

JsonToString converts a JSON to a string.

Types

type Header struct {
	Key   string
	Value string
}

Header represents an header value.

type Test

type Test struct {
	Description string

	// Test input
	Route   string
	Method  string
	Body    io.Reader
	Headers []Header

	// Check
	CheckError bool
	CheckBody  bool
	CheckCode  bool

	// Expected output
	ExpectedError bool
	ExpectedCode  int
	ExpectedBody  string
}

Test defines a structure for specifying input and output data of a single test case.

type TestDB

type TestDB struct {
	DB    *db.DB
	Token string
	// contains filtered or unexported fields
}

TestDB is used to create and use a database for tests.

func Init

func Init(p string) TestDB

Init initializes configuration from .env path and returns TestDB.

func (*TestDB) Drop

func (tdb *TestDB) Drop() error

Drop database after the test.

Jump to

Keyboard shortcuts

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