testx

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MockRedis

func MockRedis() (redisx.Client, redismock.ClientMock)

func NewLog

func NewLog() *logx.Logger

func NewMiniRedis

func NewMiniRedis() redisx.Client

func NewRedisCluster

func NewRedisCluster() redisx.Client

Types

type AnyTime

type AnyTime struct{}

AnyTime 表示任何时间的结构,只验证是否是时间类型,不匹配时间的值

func (AnyTime) Match

func (a AnyTime) Match(v driver.Value) bool

Match satisfies sqlmock.Argument interface

type Logger

type Logger struct {
	*testing.T
	// contains filtered or unexported fields
}

func Wrap

func Wrap(t *testing.T) *Logger

Wrap a point of testing.T to Logger.

func (*Logger) Case

func (l *Logger) Case(format string, args ...any)

Case is a method to start a new test case, the format parameter will describe the case's purpose, given condition, and expecting results.

func (*Logger) Fail

func (l *Logger) Fail(format string, args ...any)

Fail is an opposite method to Pass, it indicate that current condition does not match the expecting result.

func (*Logger) Fatal added in v1.0.1

func (l *Logger) Fatal(cond bool, desc string, args ...any)

func (*Logger) NoErr added in v1.0.1

func (l *Logger) NoErr(err error)

func (*Logger) NoErrf added in v1.0.1

func (l *Logger) NoErrf(err error, desc string, args ...any)

func (*Logger) Pass

func (l *Logger) Pass(format string, args ...any)

Pass is a method who invoking indicate that current condition matches the expecting result.

func (*Logger) Quit

func (l *Logger) Quit(format string, args ...any)

func (*Logger) Require

func (l *Logger) Require(cond bool, desc string, args ...any)

Require is a convenient method for Pass and Fail, it requires the given bool parameter named "cond" to be true, if so it will invoke Pass, otherwise invoke Fail.

func (*Logger) Title

func (l *Logger) Title(format string, args ...any)

Title is a method to log current test cases(i.e. current method)'s title, which is a brief description for current test cases.

type MockDB

type MockDB struct {
	*sql.DB
	sqlmock.Sqlmock
}

func NewSqlmock

func NewSqlmock() *MockDB

func (*MockDB) Gorm

func (m *MockDB) Gorm() *MockGorm

type MockGorm

type MockGorm struct {
	*MockDB
	DB *gorm.DB
}

Jump to

Keyboard shortcuts

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