tests

package module
v0.0.0-...-4b7bb1d Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2025 License: MIT Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	Model
	UserID   uint
	Name     string
	Province string
	User     *User
}

type Author

type Author struct {
	Model
	BookID uint   `db:"book_id"`
	Name   string `db:"name"`
}

func (*Author) Factory

func (r *Author) Factory() factory.Factory

type AuthorFactory

type AuthorFactory struct {
}

func (*AuthorFactory) Definition

func (r *AuthorFactory) Definition() map[string]any

type Book

type Book struct {
	Model
	UserID uint
	Name   string
	User   *User
	Author *Author
}

type Box

type Box struct {
	Model
	SoftDeletes
	Name string
}

func (*Box) Connection

func (r *Box) Connection() string

type Container

type Container struct {
	// contains filtered or unexported fields
}

func NewContainer

func NewContainer(databaseDriver docker.DatabaseDriver) *Container

func (*Container) Build

func (r *Container) Build() (docker.DatabaseDriver, error)

func (*Container) Builds

func (r *Container) Builds(num int) ([]docker.DatabaseDriver, error)

func (*Container) Ready

func (r *Container) Ready() error

func (*Container) Remove

func (r *Container) Remove() error

type GlobalScope

type GlobalScope struct {
	Model
	Name      string
	DeletedAt gorm.DeletedAt `gorm:"column:deleted_at" json:"deleted_at" db:"deleted_at"`
}

func (*GlobalScope) GlobalScopes

func (r *GlobalScope) GlobalScopes() []func(contractsorm.Query) contractsorm.Query

type House

type House struct {
	Model
	Name          string
	HouseableID   uint
	HouseableType string
}

func (*House) Factory

func (r *House) Factory() string

type JsonData

type JsonData struct {
	Model
	Data string
}

type Model

type Model struct {
	ID uint `gorm:"primaryKey" json:"id"`
	Timestamps
}

type MorphableEntity

type MorphableEntity struct {
	Model
	Name          string `json:"name"`
	MorphableID   uint   `json:"morphable_id"`
	MorphableType string `json:"morphable_type"`
}

MorphableEntity for testing polymorphic relationships

type People

type People struct {
	Model
	SoftDeletes
	Body string
}

func (*People) Connection

func (r *People) Connection() string

type Person

type Person struct {
	Model
	SoftDeletes
	Name string
}

func (*Person) Connection

func (r *Person) Connection() string

type Phone

type Phone struct {
	Model
	Name          string
	PhoneableID   uint
	PhoneableType string
}

type Product

type Product struct {
	Model
	SoftDeletes
	Name   string `db:"name"`
	Weight *int   `db:"weight"`
	Height *int   `db:"height"`
}

func (*Product) Connection

func (r *Product) Connection() string

type Review

type Review struct {
	Model
	SoftDeletes
	Body string
}

func (*Review) Connection

func (r *Review) Connection() string

type Role

type Role struct {
	Model
	Name   string
	Avatar string
	Users  []*User `gorm:"many2many:role_user"`
}

type Schema

type Schema struct {
	Model
	Name string
}

func (*Schema) TableName

func (r *Schema) TableName() string

type SoftDeletes

type SoftDeletes struct {
	DeletedAt gorm.DeletedAt `gorm:"column:deleted_at" json:"deleted_at" db:"deleted_at"`
}

type TestQuery

type TestQuery struct {
	// contains filtered or unexported fields
}

func NewTestQuery

func NewTestQuery(ctx context.Context, driver contractsdriver.Driver, config config.Config, connection string) (*TestQuery, error)

func (*TestQuery) Config

func (r *TestQuery) Config() config.Config

func (*TestQuery) CreateTable

func (r *TestQuery) CreateTable(testTables ...TestTable)

func (*TestQuery) DB

func (r *TestQuery) DB() contractsdb.DB

func (*TestQuery) Driver

func (r *TestQuery) Driver() contractsdriver.Driver

func (*TestQuery) MockConfig

func (r *TestQuery) MockConfig() *mocksconfig.Config

func (*TestQuery) Query

func (r *TestQuery) Query() orm.Query

func (*TestQuery) WithSchema

func (r *TestQuery) WithSchema(schema string)

type TestQueryBuilder

type TestQueryBuilder struct {
}

func NewTestQueryBuilder

func NewTestQueryBuilder() *TestQueryBuilder

func (*TestQueryBuilder) All

func (r *TestQueryBuilder) All(prefix string, singular bool) map[string]*TestQuery

func (*TestQueryBuilder) AllWithReadWrite

func (r *TestQueryBuilder) AllWithReadWrite() map[string]map[string]*TestQuery

func (*TestQueryBuilder) AllWithTimezone

func (r *TestQueryBuilder) AllWithTimezone(timezone string) map[string]*TestQuery

func (*TestQueryBuilder) Mysql

func (r *TestQueryBuilder) Mysql(prefix string, singular bool) *TestQuery

func (*TestQueryBuilder) MysqlWithReadWrite

func (r *TestQueryBuilder) MysqlWithReadWrite() map[string]*TestQuery

func (*TestQueryBuilder) MysqlWithTimezone

func (r *TestQueryBuilder) MysqlWithTimezone(timezone string) *TestQuery

func (*TestQueryBuilder) Postgres

func (r *TestQueryBuilder) Postgres(prefix string, singular bool) *TestQuery

func (*TestQueryBuilder) PostgresWithReadWrite

func (r *TestQueryBuilder) PostgresWithReadWrite() map[string]*TestQuery

func (*TestQueryBuilder) PostgresWithTimezone

func (r *TestQueryBuilder) PostgresWithTimezone(timezone string) *TestQuery

func (*TestQueryBuilder) Sqlite

func (r *TestQueryBuilder) Sqlite(prefix string, singular bool) *TestQuery

func (*TestQueryBuilder) SqliteWithReadWrite

func (r *TestQueryBuilder) SqliteWithReadWrite() map[string]*TestQuery

func (*TestQueryBuilder) SqliteWithTimezone

func (r *TestQueryBuilder) SqliteWithTimezone(timezone string) *TestQuery

func (*TestQueryBuilder) Sqlserver

func (r *TestQueryBuilder) Sqlserver(prefix string, singular bool) *TestQuery

func (*TestQueryBuilder) SqlserverWithReadWrite

func (r *TestQueryBuilder) SqlserverWithReadWrite() map[string]*TestQuery

func (*TestQueryBuilder) SqlserverWithTimezone

func (r *TestQueryBuilder) SqlserverWithTimezone(timezone string) *TestQuery

type TestTable

type TestTable int
const (
	TestTableAddresses TestTable = iota
	TestTableAuthors
	TestTableBooks
	TestTableHouses
	TestTablePeoples
	TestTablePhones
	TestTableProducts
	TestTableReviews
	TestTableRoles
	TestTableRoleUser
	TestTableUsers
	TestTableUser
	TestTableSchema
	TestTableJsonData
	TestTableGlobalScopes
	TestTableUuidEntities
	TestTableUlidEntities
	TestTableMorphableEntities
	TestTableUuidMorphableEntities
	TestTableUlidMorphableEntities
)

type Timestamps

type Timestamps struct {
	CreatedAt *carbon.DateTime `gorm:"autoCreateTime;column:created_at" json:"created_at" db:"created_at"`
	UpdatedAt *carbon.DateTime `gorm:"autoUpdateTime;column:updated_at" json:"updated_at" db:"updated_at"`
}

type UlidEntity

type UlidEntity struct {
	ID   string `gorm:"primaryKey;type:char(26)" json:"id"`
	Name string `json:"name"`
	Timestamps
}

UlidEntity model for testing ULID columns

type UlidMorphableEntity

type UlidMorphableEntity struct {
	Model
	Name          string `json:"name"`
	MorphableID   string `gorm:"type:char(26)" json:"morphable_id"`
	MorphableType string `json:"morphable_type"`
}

UlidMorphableEntity for testing ULID morphs

type User

type User struct {
	Model
	SoftDeletes
	Name    string
	Bio     *string
	Avatar  string
	Address *Address
	Books   []*Book
	House   *House   `gorm:"polymorphic:Houseable"`
	Phones  []*Phone `gorm:"polymorphic:Phoneable"`
	Roles   []*Role  `gorm:"many2many:role_user"`
	// contains filtered or unexported fields
}

func (*User) DispatchesEvents

func (r *User) DispatchesEvents() map[contractsorm.EventType]func(contractsorm.Event) error

func (*User) Factory

func (r *User) Factory() factory.Factory

type UserFactory

type UserFactory struct {
}

func (*UserFactory) Definition

func (r *UserFactory) Definition() map[string]any

type UserObserver

type UserObserver struct{}

func (*UserObserver) Created

func (r *UserObserver) Created(event contractsorm.Event) error

func (*UserObserver) Creating

func (r *UserObserver) Creating(event contractsorm.Event) error

func (*UserObserver) Deleted

func (r *UserObserver) Deleted(event contractsorm.Event) error

func (*UserObserver) ForceDeleted

func (r *UserObserver) ForceDeleted(event contractsorm.Event) error

func (*UserObserver) Updated

func (r *UserObserver) Updated(event contractsorm.Event) error

type UuidEntity

type UuidEntity struct {
	Model
	Uuid string `json:"uuid"`
	Name string `json:"name"`
}

UuidEntity model for testing UUID columns

type UuidMorphableEntity

type UuidMorphableEntity struct {
	Model
	Name          string `json:"name"`
	MorphableID   string `gorm:"type:uuid" json:"morphable_id"`
	MorphableType string `json:"morphable_type"`
}

UuidMorphableEntity for testing UUID morphs

Jump to

Keyboard shortcuts

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