Documentation
¶
Overview ¶
Package fixture contains all stuctures neesessary for consinstent testing on a wide range of SQL database dialects.
Index ¶
- Constants
- func GetSQL(dialect string, key string) string
- func TestEngine() *engine.Engine
- type Address
- type Animal
- type CalculateField
- type CalculateFieldCategory
- type CalculateFieldChild
- type Cat
- type Category
- type Comment
- type Company
- type CreditCard
- type CustomColumnAndIgnoredFieldClash
- type CustomizeColumn
- type Dog
- type Email
- type EmbeddedField
- type Hamster
- type JoinTable
- type Language
- type NotSoLongTableName
- type NullTime
- type NullValue
- type Num
- type Post
- type Product
- type ReallyLongTableNameToTestMySQLNameLengthLimit
- type ReallyLongThingThatReferencesShort
- type Role
- type Short
- type Toy
- type User
Constants ¶
const ( CreateTable1 = "create_table_1" CreateTable2 = "create_table_2" DropTable = "drop_table" AutoMigrate = "automigrate" SaveSQL = "save_sql" UpdateSQL = "update_sql" SingularTable = "singular_table" FirstSQL1 = "first_sql_1" FirstSQL2 = "first_sql_2" LastSQL1 = "last_sql_1" LastSQL2 = "last_sql_2" FindSQL1 = "find_sql_1" FindSQL2 = "find_sql_2" AddIndexSQL = "add_index_sql" DeleteSQL = "delete_sql" AddUniqueIndex = "add_unique_index" )
keys for storing expected output
Variables ¶
This section is empty.
Functions ¶
func TestEngine ¶
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 ¶
CalculateFieldCategory fixture
type CalculateFieldChild ¶
CalculateFieldChild fixture
type CreditCard ¶
type CreditCard struct { ID int64 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 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 NotSoLongTableName ¶
type NotSoLongTableName struct { ID int64 ReallyLongThingID int64 ReallyLongThing ReallyLongTableNameToTestMySQLNameLengthLimit }
NotSoLongTableName fixture
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 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 ¶
ReallyLongThingThatReferencesShort 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