tests

package
v1.25.12 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: MIT Imports: 13 Imported by: 68

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertEqual

func AssertEqual(t *testing.T, got, expect interface{})

func AssertObjEqual

func AssertObjEqual(t *testing.T, r, e interface{}, names ...string)

func Now

func Now() *time.Time

Types

type Account

type Account struct {
	gorm.Model
	UserID sql.NullInt64
	Number string
}

type Child added in v1.23.3

type Child struct {
	gorm.Model
	Name     string
	ParentID *uint
	Parent   *Parent
}

type Company

type Company struct {
	ID   int
	Name string
}

type Coupon added in v1.22.4

type Coupon struct {
	ID               int              `gorm:"primarykey; size:255"`
	AppliesToProduct []*CouponProduct `gorm:"foreignKey:CouponId;constraint:OnDelete:CASCADE"`
	AmountOff        uint32           `gorm:"column:amount_off"`
	PercentOff       float32          `gorm:"column:percent_off"`
}

type CouponProduct added in v1.22.4

type CouponProduct struct {
	CouponId  int    `gorm:"primarykey;size:255"`
	ProductId string `gorm:"primarykey;size:255"`
	Desc      string
}

type DummyDialector

type DummyDialector struct {
	TranslatedErr error
}

func (DummyDialector) BindVarTo

func (DummyDialector) BindVarTo(writer clause.Writer, stmt *gorm.Statement, v interface{})

func (DummyDialector) DataTypeOf

func (DummyDialector) DataTypeOf(*schema.Field) string

func (DummyDialector) DefaultValueOf added in v0.2.10

func (DummyDialector) DefaultValueOf(field *schema.Field) clause.Expression

func (DummyDialector) Explain

func (DummyDialector) Explain(sql string, vars ...interface{}) string

func (DummyDialector) Initialize

func (DummyDialector) Initialize(db *gorm.DB) error

func (DummyDialector) Migrator

func (DummyDialector) Migrator(*gorm.DB) gorm.Migrator

func (DummyDialector) Name

func (DummyDialector) Name() string

func (DummyDialector) QuoteTo

func (DummyDialector) QuoteTo(writer clause.Writer, str string)

func (DummyDialector) Translate added in v1.25.0

func (d DummyDialector) Translate(err error) error

type Language

type Language struct {
	Code string `gorm:"primarykey"`
	Name string
}

type Order added in v1.22.4

type Order struct {
	gorm.Model
	Num      string
	Coupon   *Coupon
	CouponID string
}

type Parent added in v1.23.3

type Parent struct {
	gorm.Model
	FavChildID uint
	FavChild   *Child
	Children   []*Child
}

type Pet

type Pet struct {
	gorm.Model
	UserID *uint
	Name   string
	Toy    Toy `gorm:"polymorphic:Owner;"`
}

type Tools added in v1.25.6

type Tools struct {
	gorm.Model
	Name     string
	CustomID string
	Type     string
}

type Toy

type Toy struct {
	gorm.Model
	Name      string
	OwnerID   string
	OwnerType string
}

type User

type User struct {
	gorm.Model
	Name      string
	Age       uint
	Birthday  *time.Time
	Account   Account
	Pets      []*Pet
	NamedPet  *Pet
	Toys      []Toy   `gorm:"polymorphic:Owner"`
	Tools     []Tools `gorm:"polymorphicType:Type;polymorphicId:CustomID"`
	CompanyID *int
	Company   Company
	ManagerID *uint
	Manager   *User
	Team      []User     `gorm:"foreignkey:ManagerID"`
	Languages []Language `gorm:"many2many:UserSpeak;"`
	Friends   []*User    `gorm:"many2many:user_friends;"`
	Active    bool
}

User has one `Account` (has one), many `Pets` (has many) and `Toys` (has many - polymorphic) He works in a Company (belongs to), he has a Manager (belongs to - single-table), and also managed a Team (has many - single-table) He speaks many languages (many to many) and has many friends (many to many - single-table) His pet also has one Toy (has one - polymorphic) NamedPet is a reference to a named `Pet` (has one)

Jump to

Keyboard shortcuts

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