tests

package
v0.0.0-...-39efa14 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultTester = &Tester{}
	UserTester    = &Tester{ID: 1}
	AdminTester   = &Tester{ID: 2}
	OtherTester   = map[int]*Tester{
		0: DefaultTester,
		1: UserTester,
		2: AdminTester,
	} // map[userID]Tester
)
View Source
var App *fiber.App
View Source
var DB *gorm.DB

Functions

func RegisterApp

func RegisterApp(app *fiber.App)

RegisterApp registers the fiber app to the package It should be called before any test

func TestAuth

func TestAuth(t *testing.T)

Types

type RequestConfig

type RequestConfig struct {
	RequestHeaders map[string]string
	RequestQuery   any
	RequestBody    any
	ResponseModel  any
	ExpectedBody   string
	ContentType    string `default:"application/json"`
}

RequestConfig is a struct that contains the config of a request

type Tester

type Tester struct {
	ID    int    `json:"id"`
	Token string `json:"token"`
}

Tester is a struct that mocks a request user

func (*Tester) Delete

func (tester *Tester) Delete(t assert.TestingT, route string, status int, config RequestConfig)

func (*Tester) Get

func (tester *Tester) Get(t assert.TestingT, route string, status int, config RequestConfig)

func (*Tester) Patch

func (tester *Tester) Patch(t assert.TestingT, route string, status int, config RequestConfig)

func (*Tester) Post

func (tester *Tester) Post(t assert.TestingT, route string, status int, config RequestConfig)

func (*Tester) Put

func (tester *Tester) Put(t assert.TestingT, route string, status int, config RequestConfig)

func (*Tester) Request

func (tester *Tester) Request(t assert.TestingT, method string, route string, status int, config RequestConfig)

Jump to

Keyboard shortcuts

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