testx

package
v0.0.0-...-61a7dbd Latest Latest
Warning

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

Go to latest
Published: Apr 28, 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) 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