fixture

package
v0.0.0-...-9ed695e Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2017 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package fixture contains all stuctures neesessary for consinstent testing on a wide range of SQL database dialects.

Index

Constants

View Source
const (
	CreateTable1  = "ceate_table_1"
	CreateTable2  = "ceate_table_2"
	DropTable     = "drop_table"
	AutoMigrate   = "automigrate"
	SaveSQL       = "sqve_sql"
	UpdateSQL     = "update_sql"
	SingularTable = "singular_table"
	FirstSQL1     = "firsr_sql_1"
	FirstSQL2     = "firsr_sql_2"
)

Variables

This section is empty.

Functions

func GetSQL

func GetSQL(dialect string, key string) string

func TestEngine

func TestEngine() *engine.Engine

TestEngine returns an *engine.Engine instance suitable for testing

Types

type Address

type Address struct {
	ID        int
	Address1  string
	Address2  string
	Post      string
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time
}

Address fixture

type Animal

type Animal struct {
	Counter uint64    `gorm:"primary_key:yes"`
	Name    string    `sql:"DEFAULT:'galeone'"`
	From    string    //test reserved sql keyword as field name
	Age     time.Time `sql:"DEFAULT:current_timestamp"`

	CreatedAt time.Time
	UpdatedAt time.Time
	// contains filtered or unexported fields
}

Animal fixture

type CalculateField

type CalculateField struct {
	model.Model
	Name     string
	Children []CalculateFieldChild
	Category CalculateFieldCategory
	EmbeddedField
}

CalculateField fixture

type CalculateFieldCategory

type CalculateFieldCategory struct {
	model.Model
	CalculateFieldID uint
	Name             string
}

CalculateFieldCategory fixture

type CalculateFieldChild

type CalculateFieldChild struct {
	model.Model
	CalculateFieldID uint
	Name             string
}

CalculateFieldChild fixture

type Cat

type Cat struct {
	ID   int
	Name string
	Toy  Toy `gorm:"polymorphic:Owner;"`
}

Cat fixture

type Category

type Category struct {
	model.Model
	Name string

	Categories []Category
	CategoryID *uint
}

Category fixture

type Comment

type Comment struct {
	model.Model
	PostID  int64
	Content string
	Post    Post
}

Comment fixture

type Company

type Company struct {
	ID    int64
	Name  string
	Owner *User `sql:"-"`
}

Company fixture

type CreditCard

type CreditCard struct {
	ID        int8
	Number    string
	UserID    sql.NullInt64
	CreatedAt time.Time `sql:"not null"`
	UpdatedAt time.Time
	DeletedAt *time.Time
}

CreditCard fixture

type CustomColumnAndIgnoredFieldClash

type CustomColumnAndIgnoredFieldClash struct {
	Body    string `sql:"-"`
	RawBody string `gorm:"column:body"`
}

CustomColumnAndIgnoredFieldClash fixture Make sure an ignored field does not interfere with another field's custom column name that matches the ignored field.

type CustomizeColumn

type CustomizeColumn struct {
	ID   int64      `gorm:"column:mapped_id; primary_key:yes"`
	Name string     `gorm:"column:mapped_name"`
	Date *time.Time `gorm:"column:mapped_time"`
}

CustomizeColumn fixture

type Dog

type Dog struct {
	ID   int
	Name string
	Toys []Toy `gorm:"polymorphic:Owner;"`
}

Dog fixture

type Email

type Email struct {
	ID        int16
	UserID    int
	Email     string `sql:"type:varchar(100);"`
	CreatedAt time.Time
	UpdatedAt time.Time
}

Email fixture

type EmbeddedField

type EmbeddedField struct {
	EmbeddedName string `sql:"NOT NULL;DEFAULT:'hello'"`
}

EmbeddedField fixture

type Hamster

type Hamster struct {
	ID           int
	Name         string
	PreferredToy Toy `gorm:"polymorphic:Owner;polymorphic_value:hamster_preferred"`
	OtherToy     Toy `gorm:"polymorphic:Owner;polymorphic_value:hamster_other"`
}

Hamster fixture

type JoinTable

type JoinTable struct {
	From uint64
	To   uint64
	Time time.Time `sql:"default: null"`
}

JoinTable fixture

type Language

type Language struct {
	model.Model
	Name  string
	Users []User `gorm:"many2many:user_languages;"`
}

Language fixture

type NotSoLongTableName

type NotSoLongTableName struct {
	ID                int64
	ReallyLongThingID int64
	ReallyLongThing   ReallyLongTableNameToTestMySQLNameLengthLimit
}

NotSoLongTableName fixture

type NullTime

type NullTime struct {
	Time  time.Time
	Valid bool
}

NullTime fixture

func (*NullTime) Scan

func (nt *NullTime) Scan(value interface{}) error

Scan implents sql.Scanner

func (NullTime) Value

func (nt NullTime) Value() (driver.Value, error)

Value implements driver.valuer

type NullValue

type NullValue struct {
	ID      int64
	Name    sql.NullString  `sql:"not null"`
	Gender  *sql.NullString `sql:"not null"`
	Age     sql.NullInt64
	Male    sql.NullBool
	Height  sql.NullFloat64
	AddedAt NullTime
}

NullValue fixture

type Num

type Num int64

Num custom int64 type

func (*Num) Scan

func (i *Num) Scan(src interface{}) error

Scan implements sql.Scanner

type Post

type Post struct {
	ID             int64
	CategoryID     sql.NullInt64
	MainCategoryID int64
	Title          string
	Body           string
	Comments       []*Comment
	Category       Category
	MainCategory   Category
}

Post fixture

type Product

type Product struct {
	ID                    int64
	Code                  string
	Price                 int64
	CreatedAt             time.Time
	UpdatedAt             time.Time
	AfterFindCallTimes    int64
	BeforeCreateCallTimes int64
	AfterCreateCallTimes  int64
	BeforeUpdateCallTimes int64
	AfterUpdateCallTimes  int64
	BeforeSaveCallTimes   int64
	AfterSaveCallTimes    int64
	BeforeDeleteCallTimes int64
	AfterDeleteCallTimes  int64
}

Product fixture

type ReallyLongTableNameToTestMySQLNameLengthLimit

type ReallyLongTableNameToTestMySQLNameLengthLimit struct {
	ID int64
}

ReallyLongTableNameToTestMySQLNameLengthLimit fixture

type ReallyLongThingThatReferencesShort

type ReallyLongThingThatReferencesShort struct {
	ID      int64
	ShortID int64
	Short   Short
}

ReallyLongThingThatReferencesShort fixture

type Role

type Role struct {
	Name string `gorm:"size:256"`
}

Role fixture

func (Role) IsAdmin

func (role Role) IsAdmin() bool

IsAdmin return true if the role is admin

func (*Role) Scan

func (role *Role) Scan(value interface{}) error

Scan implements sql.Scanner

func (Role) Value

func (role Role) Value() (driver.Value, error)

Value implements sql driver.Valuer

type Short

type Short struct {
	ID int64
}

Short fixture

type Toy

type Toy struct {
	ID        int
	Name      string
	OwnerID   int
	OwnerType string
}

Toy fixture

type User

type User struct {
	ID                int64
	Age               int64
	UserNum           Num
	Name              string `sql:"size:255"`
	Email             string
	Birthday          *time.Time    // Time
	CreatedAt         time.Time     // CreatedAt: Time of record is created, will be insert automatically
	UpdatedAt         time.Time     // UpdatedAt: Time of record is updated, will be updated automatically
	Emails            []Email       // Embedded structs
	BillingAddress    Address       // Embedded struct
	BillingAddressID  sql.NullInt64 // Embedded struct's foreign key
	ShippingAddress   Address       // Embedded struct
	ShippingAddressID int64         // Embedded struct's foreign key
	CreditCard        CreditCard
	Latitude          float64
	Languages         []Language `gorm:"many2many:user_languages;"`
	CompanyID         *int
	Company           Company
	Role
	PasswordHash      []byte
	Sequence          uint                  `gorm:"AUTO_INCREMENT"`
	IgnoreMe          int64                 `sql:"-"`
	IgnoreStringSlice []string              `sql:"-"`
	Ignored           struct{ Name string } `sql:"-"`
	IgnoredPointer    *User                 `sql:"-"`
}

User fixture

Jump to

Keyboard shortcuts

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