tests

package
v0.0.0-...-c86d00c Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: Apache-2.0 Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupTestDB

func CleanupTestDB(db *gorm.DB)

CleanupTestDB clears the database after each test if needed

func InitTestDB

func InitTestDB() *gorm.DB

InitTestDB makes a connection to the test database

func RunTests

func RunTests(db *gorm.DB, t *testing.T, testCases []TestCase, baseURL string, handler http.HandlerFunc)

RunTests iterates through the given test cases and runs them using the provided handler

func SetupDBEntries

func SetupDBEntries(filePath string, db *gorm.DB, t *testing.T)

SetupDBEntries reads a SQL file required for tests and executes it

func SetupTestDB

func SetupTestDB(t *testing.T) *gorm.DB

SetupTestDB sets up the database env vars with the current test

Types

type TestCase

type TestCase struct {
	Name         string
	ReqHeaders   interface{}
	ReqBody      interface{}
	ExpectedCode int
	ExpectedBody string
	QueryParams  string
	RequestType  string
}

TestCase is a struct used to store expected and returned values when running tests

Jump to

Keyboard shortcuts

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