specs

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package specs defines test specifications for rel's adapter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Aggregate

func Aggregate(t *testing.T, repo rel.Repository)

Aggregate tests count specifications.

func CheckConstraintOnInsert added in v0.11.0

func CheckConstraintOnInsert(t *testing.T, repo rel.Repository)

CheckConstraintOnInsert tests foreign key constraint specifications on insert.

func CheckConstraintOnUpdate added in v0.11.0

func CheckConstraintOnUpdate(t *testing.T, repo rel.Repository)

CheckConstraintOnUpdate tests foreign key constraint specifications.

func Delete

func Delete(t *testing.T, repo rel.Repository)

Delete tests delete specifications.

func DeleteAll

func DeleteAll(t *testing.T, repo rel.Repository)

DeleteAll tests delete all specifications.

func DeleteBelongsTo

func DeleteBelongsTo(t *testing.T, repo rel.Repository)

DeleteBelongsTo tests delete specifications.

func DeleteHasMany

func DeleteHasMany(t *testing.T, repo rel.Repository)

DeleteHasMany tests delete specifications.

func DeleteHasOne

func DeleteHasOne(t *testing.T, repo rel.Repository)

DeleteHasOne tests delete specifications.

func ForeignKeyConstraintOnInsert added in v0.11.0

func ForeignKeyConstraintOnInsert(t *testing.T, repo rel.Repository)

ForeignKeyConstraintOnInsert tests foreign key constraint specifications on insert.

func ForeignKeyConstraintOnUpdate added in v0.11.0

func ForeignKeyConstraintOnUpdate(t *testing.T, repo rel.Repository)

ForeignKeyConstraintOnUpdate tests foreign key constraint specifications on update.

func Insert

func Insert(t *testing.T, repo rel.Repository)

Insert tests specification for database insertion.

func InsertAll

func InsertAll(t *testing.T, repo rel.Repository)

InsertAll tests insert multiple specifications.

func InsertAllPartialCustomPrimary

func InsertAllPartialCustomPrimary(t *testing.T, repo rel.Repository)

InsertAllPartialCustomPrimary tests insert multiple specifications.

func InsertBelongsTo

func InsertBelongsTo(t *testing.T, repo rel.Repository)

InsertBelongsTo tests specification for insertion with belongs to association.

func InsertHasMany

func InsertHasMany(t *testing.T, repo rel.Repository)

InsertHasMany tests specification insertion with has many association.

func InsertHasOne

func InsertHasOne(t *testing.T, repo rel.Repository)

InsertHasOne tests specification for insertion with has one association.

func Inserts

func Inserts(t *testing.T, repo rel.Repository)

Inserts tests insert specifications.

func Migrate

func Migrate(t *testing.T, repo rel.Repository, flags ...Flag)

Migrate specs.

func PreloadBelongsTo

func PreloadBelongsTo(t *testing.T, repo rel.Repository)

PreloadBelongsTo tests specification for preloading belongs to association.

func PreloadBelongsToSlice

func PreloadBelongsToSlice(t *testing.T, repo rel.Repository)

PreloadBelongsToSlice tests specification for preloading belongs to association from multiple records.

func PreloadBelongsToWithQuery

func PreloadBelongsToWithQuery(t *testing.T, repo rel.Repository)

PreloadBelongsToWithQuery tests specification for preloading belongs to association.

func PreloadHasMany

func PreloadHasMany(t *testing.T, repo rel.Repository)

PreloadHasMany tests specification for preloading has many association.

func PreloadHasManySlice

func PreloadHasManySlice(t *testing.T, repo rel.Repository)

PreloadHasManySlice tests specification for preloading has many association from multiple records.

func PreloadHasManyWithQuery

func PreloadHasManyWithQuery(t *testing.T, repo rel.Repository)

PreloadHasManyWithQuery tests specification for preloading has many association.

func PreloadHasOne

func PreloadHasOne(t *testing.T, repo rel.Repository)

PreloadHasOne tests specification for preloading has one association.

func PreloadHasOneSlice

func PreloadHasOneSlice(t *testing.T, repo rel.Repository)

PreloadHasOneSlice tests specification for preloading has one association from multiple records.

func PreloadHasOneWithQuery

func PreloadHasOneWithQuery(t *testing.T, repo rel.Repository)

PreloadHasOneWithQuery tests specification for preloading has one association.

func Query

func Query(t *testing.T, repo rel.Repository)

Query tests query specifications without join.

func QueryJoin

func QueryJoin(t *testing.T, repo rel.Repository)

QueryJoin tests query specifications with join.

func QueryNotFound

func QueryNotFound(t *testing.T, repo rel.Repository)

QueryNotFound tests query specifications when no result found.

func QueryWhereSubQuery added in v0.13.0

func QueryWhereSubQuery(t *testing.T, repo rel.Repository, flags ...Flag)

Query tests query specifications without join.

func Setup

func Setup(t *testing.T, repo rel.Repository) func()

Setup database for specs execution.

func UniqueConstraintOnInsert added in v0.11.0

func UniqueConstraintOnInsert(t *testing.T, repo rel.Repository)

UniqueConstraintOnInsert tests unique constraint specifications on insert.

func UniqueConstraintOnUpdate added in v0.11.0

func UniqueConstraintOnUpdate(t *testing.T, repo rel.Repository)

UniqueConstraintOnUpdate tests unique constraint specifications on insert.

func Update

func Update(t *testing.T, repo rel.Repository)

Update tests specification for updating a record.

func UpdateAll

func UpdateAll(t *testing.T, repo rel.Repository)

UpdateAll tests update all specifications.

func UpdateAtomic

func UpdateAtomic(t *testing.T, repo rel.Repository)

UpdateAtomic tests increment and decerement operation when updating a record.

func UpdateBelongsToInsert

func UpdateBelongsToInsert(t *testing.T, repo rel.Repository)

UpdateBelongsToInsert tests specification for updating a record and inserting belongs to association.

func UpdateBelongsToUpdate

func UpdateBelongsToUpdate(t *testing.T, repo rel.Repository)

UpdateBelongsToUpdate tests specification for updating a record and updating belongs to association.

func UpdateHasManyInsert

func UpdateHasManyInsert(t *testing.T, repo rel.Repository)

UpdateHasManyInsert tests specification for updating a record and inserting has many association.

func UpdateHasManyReplace

func UpdateHasManyReplace(t *testing.T, repo rel.Repository)

UpdateHasManyReplace tests specification for updating a record and replacing has many association.

func UpdateHasManyUpdate

func UpdateHasManyUpdate(t *testing.T, repo rel.Repository)

UpdateHasManyUpdate tests specification for updating a record and updating has many association.

func UpdateHasOneInsert

func UpdateHasOneInsert(t *testing.T, repo rel.Repository)

UpdateHasOneInsert tests specification for updating a record and inserting has many association.

func UpdateHasOneReplace

func UpdateHasOneReplace(t *testing.T, repo rel.Repository)

UpdateHasOneReplace tests specification for updating a record and replacing has one association.

func UpdateHasOneUpdate

func UpdateHasOneUpdate(t *testing.T, repo rel.Repository)

UpdateHasOneUpdate tests specification for updating a record and updating has one association.

func UpdateNotFound

func UpdateNotFound(t *testing.T, repo rel.Repository)

UpdateNotFound tests specification for updating a not found record.

func Updates

func Updates(t *testing.T, repo rel.Repository)

Updates tests update specifications.

Types

type Address

type Address struct {
	ID        int64
	User      User `autosave:"true"`
	UserID    *int64
	Name      string
	CreatedAt time.Time
	UpdatedAt time.Time
}

Address defines addresses schema.

type Composite

type Composite struct {
	Primary1 int `db:",primary"`
	Primary2 int `db:",primary"`
	Data     string
}

Composite primaries example.

type Extra

type Extra struct {
	ID     uint
	Slug   *string
	Score  int
	UserID int64
}

Extra defines extra schema.

type Flag

type Flag int

Flag for configuration.

const (
	// SkipDropColumn spec.
	SkipDropColumn Flag = 1 << iota
	// SkipRenameColumn spec.
	SkipRenameColumn
	// SkipAllAndAnyKeyword spec.
	SkipAllAndAnyKeyword
)

type User

type User struct {
	ID             int64
	Name           string
	Gender         string
	Age            int
	Note           *string
	Addresses      []Address `autosave:"true"`
	PrimaryAddress *Address  `autosave:"true"`
	CreatedAt      time.Time
	UpdatedAt      time.Time
}

User defines users schema.

Jump to

Keyboard shortcuts

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