testhelper

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TEST_TABLE_USER_SQL = `` /* 207-byte string literal not displayed */

	INSERT_USER_SQL = `insert into user (name, age) values (?, ?);`
)

sql 和 model放在一起

Variables

This section is empty.

Functions

func CreateDatabase

func CreateDatabase(db *database.Db, dbName string)

创建数据库

func CreateTables

func CreateTables(db *gorm.DB, sql string)

创建表

func DropDatabase

func DropDatabase(db *database.Db, dbName string)

删除数据库

func GetTestDbName

func GetTestDbName() string

根据当前时间戳生成测试数据库名字

func InsertData

func InsertData(db *database.Db, sql string, args ...interface{})

插入数据

Types

type BaseModel

type BaseModel struct {
	Id  int `json:"id" gorm:"column:id;type:int(11);not null;primaryKey;autoIncrement"`
	Age int `json:"age" gorm:"column:age;type:int(11);not null;default:0"`
}

type User

type User struct {
	Name string `json:"name" gorm:"column:name;type:varchar(255);not null;default:''"`
	BaseModel
}

测试 User 结构体

Jump to

Keyboard shortcuts

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