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: 0

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