testUtils

package
v0.0.0-...-2d2cc06 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

package testUtils contains useful functions for writing tests

Index

Constants

View Source
const (
	DBName = "test"
)

Variables

View Source
var MockData []byte
View Source
var MockHandlerSuccess bool = false

flag to mark if MockHandler was reached. Used by the caller to check if the middleware being tested called the next middleware successfully

Functions

func CreateDBTable

func CreateDBTable(sqlFilePath string, db *sql.DB) error

func CreateTestDB

func CreateTestDB(dbName string) (*sql.DB, error)

func DeleteTestDB

func DeleteTestDB(dbName string)

func MockHandler

func MockHandler() func(w http.ResponseWriter, r *http.Request)

Types

type MockResponseWriter

type MockResponseWriter struct {
	HeaderMap http.Header
	Data      []byte
}

mock response writer object and mock implementations of its methods

func NewMockResponseWriter

func NewMockResponseWriter() *MockResponseWriter

func (MockResponseWriter) Header

func (w MockResponseWriter) Header() http.Header

func (*MockResponseWriter) Write

func (w *MockResponseWriter) Write(b []byte) (int, error)

func (MockResponseWriter) WriteHeader

func (w MockResponseWriter) WriteHeader(statusCode int)

Jump to

Keyboard shortcuts

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