testsuit

package
v0.0.0-...-b51443a Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2022 License: BSD-2-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Diff

func Diff(o1, o2 interface{}, ignoreFields ...string) string

Diff diff interface{}

func DiffMap

func DiffMap(o1, o2 interface{}, ignoreFields ...string) string

DiffMap m1,m2 must be map[interface{}]ptr

func DiffObj

func DiffObj(o1, o2 interface{}, ignoreFields ...string) string

DiffObj o1, o2 must be ptr

func DiffSlice

func DiffSlice(o1, o2 interface{}, ignoreFields ...string) string

DiffSlice o1,o2 must be []ptr

func ExistMap

func ExistMap(ss ...interface{}) map[interface{}]bool

ExistMap make key map, key must be key able

Types

type DB

type DB struct {
	// contains filtered or unexported fields
}

TestDB the struct of the manager of database

func New

func New(account, preName, sqlPath string) (*DB, error)

New return one new instance of the db account "root:@tcp(127.0.0.1:3306)"

func (*DB) ClearTables

func (d *DB) ClearTables(tables []string) error

ClearTables delete tables from database

func (*DB) Delete

func (d *DB) Delete() error

Delete drop the database

func (*DB) Master

func (d *DB) Master() *gorm.DB

Master return *gorm.DB

type Do

type Do func(*TestCase) (interface{}, error)

Do exec a test case

type TestCase

type TestCase struct {
	Desc         string
	Args         interface{}
	WantResults  interface{}
	WantErr      string
	IgnoreFileds []string
}

TestCase test case

func (*TestCase) DiffErr

func (c *TestCase) DiffErr(err error) string

DiffErr return diff want and got err, can compatibility nil

func (*TestCase) DiffResult

func (c *TestCase) DiffResult(got interface{}, ignoreFields ...string) string

DiffResult cmp want and got diff, return empty string when equal

type TestSuit

type TestSuit []*TestCase

Suit TestCases

func (TestSuit) Range

func (s TestSuit) Range(t *testing.T, do Do)

Range range test case, and do every test case

Jump to

Keyboard shortcuts

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