tester

package
v0.0.0-...-20694db Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Wter = &tester{
	tokens: make(map[string]string),
	Env:    make(map[string]any),
}

Global Restful API tester signleton.

USAGE: Init mvc.Wter configs before use it as follow:

func init() {
	// logger.SilentLoggers() // silent logger if comment out.
	mvc.Wter.Author = "WENGOLD-V2.0"
	mvc.Wter.TokenApi = "http://192.168.1.100:8000/server/token?id=%s"
	mvc.Wter.User = "12345678"
}

Functions

func NewHelper

func NewHelper() *helper

Create a data helper to query table datas.

func TestMain

func TestMain(t *testing.T, c, uid, api, method string, want int, params any)

A single testing to simulate send http request and logout test response if exist.

func TestMults

func TestMults(t *testing.T, api, method string, cases []*TestCase)

Multiple testing from given test cases.

Types

type Option

type Option func(t *helper)

Unit test helper options setter.

func WithLimit

func WithLimit(limit int) Option

Specify limit number for query result.

func WithOrder

func WithOrder(order string, desc ...string) Option

Specify order by conditions.

func WithTag

func WithTag(tag string) Option

Specify target field name as input param or output field, such as uid.

func WithWhere

func WithWhere(where pd.Wheres) Option

Specify where condition fields and values.

type TestCase

type TestCase struct {
	Case   string // Current excute unit test case.
	User   string // Http request author uuid.
	Want   int    // Http response code for pass current test.
	Params any    // Http request params, body of POST method, form data of GET method.
}

Test case datas for multiple testing.

func NewCase

func NewCase(c string, want int, param any) *TestCase

Return test case object for easy multipe testing.

func UserCase

func UserCase(user, c string, want int, param any) *TestCase

Return test case object with authed user for easy multipe testing.

type TestForm

type TestForm map[string]any

Url params form datas type.

Jump to

Keyboard shortcuts

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