Documentation
¶
Overview ¶
Package testmodels provides valid and invalid models for testing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MakeAllModels ¶
func MakeAllModels[TB testing.TB](t TB) []driver.TenantTabler
MakeAllModels returns all valid models for testing.
func MakePrivateModels ¶
func MakePrivateModels[TB testing.TB](t TB) []driver.TenantTabler
MakePrivateModels returns all valid tenant-specific models for testing.
func MakeSharedModels ¶
func MakeSharedModels[TB testing.TB](t TB) []driver.TenantTabler
MakeSharedModels returns all valid shared models for testing.
Types ¶
type Author ¶
type Author struct {
gorm.Model
Tenant Tenant `gorm:"foreignKey:TenantID"`
TenantID string
Books []*Book `gorm:"foreignKey:AuthorID"`
}
Valid models for testing.
func (Author) IsSharedModel ¶
type Book ¶
type Book struct {
gorm.Model
Title string
AuthorID uint `gorm:"index"`
Languages []*Language `gorm:"many2many:book_languages;"`
}
Valid models for testing.
func (Book) IsSharedModel ¶
type BookInvalid ¶
type BookInvalid struct{} // invalid tenant-specific model.
Invalid models for testing.
func (BookInvalid) IsSharedModel ¶
func (BookInvalid) IsSharedModel() bool
func (BookInvalid) TableName ¶
func (BookInvalid) TableName() string
type FakeTenant ¶
type FakeTenant struct {
gorm.Model
multitenancy.TenantModel
}
FakeTenant embeds gorm.Model and multitenancy.TenantModel.
func (FakeTenant) IsSharedModel ¶
func (FakeTenant) IsSharedModel() bool
func (FakeTenant) TableName ¶
func (FakeTenant) TableName() string
type Tenant ¶
type Tenant struct {
ID string `gorm:"primaryKey;size:63;check:LENGTH(id) >= 3;"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
Valid models for testing.
func (Tenant) IsSharedModel ¶
type TenantInvalid ¶
type TenantInvalid struct{} // invalid shared model.
Invalid models for testing.
func (TenantInvalid) IsSharedModel ¶
func (TenantInvalid) IsSharedModel() bool
func (TenantInvalid) TableName ¶
func (TenantInvalid) TableName() string
Click to show internal directories.
Click to hide internal directories.