testmodels

package
v8.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

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

func (Author) IsSharedModel() bool

func (Author) TableName

func (Author) TableName() string

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

func (Book) IsSharedModel() bool

func (Book) TableName

func (Book) TableName() string

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 Language

type Language struct {
	gorm.Model
	Name  string
	Books []*Book `gorm:"many2many:book_languages;"`
}

Valid models for testing.

func (Language) IsSharedModel

func (Language) IsSharedModel() bool

func (Language) TableName

func (Language) 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

func (Tenant) IsSharedModel() bool

func (Tenant) TableName

func (Tenant) TableName() string

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

Jump to

Keyboard shortcuts

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