Documentation ¶
Overview ¶
Package db_test provides some helper funcs for testing db integrations
Index ¶
- Variables
- type Cloner
- type NotIder
- type StoreTestCar
- func (*StoreTestCar) Descriptor() ([]byte, []int)deprecated
- func (x *StoreTestCar) GetCreateTime() *Timestamp
- func (x *StoreTestCar) GetModel() string
- func (x *StoreTestCar) GetMpg() int32
- func (x *StoreTestCar) GetName() string
- func (x *StoreTestCar) GetPublicId() string
- func (x *StoreTestCar) GetUpdateTime() *Timestamp
- func (*StoreTestCar) ProtoMessage()
- func (x *StoreTestCar) ProtoReflect() protoreflect.Message
- func (x *StoreTestCar) Reset()
- func (x *StoreTestCar) String() string
- type StoreTestRental
- func (*StoreTestRental) Descriptor() ([]byte, []int)deprecated
- func (x *StoreTestRental) GetCarId() string
- func (x *StoreTestRental) GetCreateTime() *Timestamp
- func (x *StoreTestRental) GetName() string
- func (x *StoreTestRental) GetUpdateTime() *Timestamp
- func (x *StoreTestRental) GetUserId() string
- func (x *StoreTestRental) GetVersion() uint32
- func (*StoreTestRental) ProtoMessage()
- func (x *StoreTestRental) ProtoReflect() protoreflect.Message
- func (x *StoreTestRental) Reset()
- func (x *StoreTestRental) String() string
- type StoreTestScooter
- func (*StoreTestScooter) Descriptor() ([]byte, []int)deprecated
- func (x *StoreTestScooter) GetCreateTime() *Timestamp
- func (x *StoreTestScooter) GetModel() string
- func (x *StoreTestScooter) GetMpg() int32
- func (x *StoreTestScooter) GetPrivateId() string
- func (x *StoreTestScooter) GetReadOnlyField() string
- func (x *StoreTestScooter) GetUpdateTime() *Timestamp
- func (*StoreTestScooter) ProtoMessage()
- func (x *StoreTestScooter) ProtoReflect() protoreflect.Message
- func (x *StoreTestScooter) Reset()
- func (x *StoreTestScooter) String() string
- type StoreTestUser
- func (*StoreTestUser) Descriptor() ([]byte, []int)deprecated
- func (x *StoreTestUser) GetCreateTime() *Timestamp
- func (x *StoreTestUser) GetEmail() string
- func (x *StoreTestUser) GetName() string
- func (x *StoreTestUser) GetPhoneNumber() string
- func (x *StoreTestUser) GetPublicId() string
- func (x *StoreTestUser) GetUpdateTime() *Timestamp
- func (x *StoreTestUser) GetVersion() uint32
- func (*StoreTestUser) ProtoMessage()
- func (x *StoreTestUser) ProtoReflect() protoreflect.Message
- func (x *StoreTestUser) Reset()
- func (x *StoreTestUser) String() string
- type TestCar
- type TestRental
- type TestScooter
- type TestUser
- type TestWithAfterCreate
- type TestWithAfterDelete
- type TestWithAfterFind
- type TestWithAfterSave
- type TestWithAfterUpdate
- type TestWithBeforeCreate
- type TestWithBeforeDelete
- type TestWithBeforeSave
- type TestWithBeforeUpdate
- type Timestamp
- func (ts *Timestamp) AsTime() time.Time
- func (*Timestamp) Descriptor() ([]byte, []int)deprecated
- func (x *Timestamp) GetTimestamp() *timestamppb.Timestamp
- func (ts *Timestamp) GormDataType() string
- func (*Timestamp) ProtoMessage()
- func (x *Timestamp) ProtoReflect() protoreflect.Message
- func (x *Timestamp) Reset()
- func (ts *Timestamp) Scan(value interface{}) error
- func (x *Timestamp) String() string
- func (ts *Timestamp) Value() (driver.Value, error)
Constants ¶
This section is empty.
Variables ¶
var ( // NegativeInfinityTS defines a value for postgres -infinity NegativeInfinityTS = time.Date(math.MinInt32, time.January, 1, 0, 0, 0, 0, time.UTC) // PositiveInfinityTS defines a value for postgres infinity PositiveInfinityTS = time.Date(math.MaxInt32, time.December, 31, 23, 59, 59, 1e9-1, time.UTC) )
var File_dbtest_storage_v1_dbtest_proto protoreflect.FileDescriptor
Functions ¶
This section is empty.
Types ¶
type StoreTestCar ¶
type StoreTestCar struct { // public_id is the used to access the car via an API // @inject_tag: gorm:"primaryKey;default:null" PublicId string `protobuf:"bytes,4,opt,name=public_id,json=publicId,proto3" json:"public_id,omitempty" gorm:"primaryKey;default:null"` // create_time from the RDBMS // @inject_tag: `gorm:"default:CURRENT_TIMESTAMP"` CreateTime *Timestamp `protobuf:"bytes,2,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty" gorm:"default:CURRENT_TIMESTAMP"` // update_time from the RDBMS // @inject_tag: `gorm:"default:CURRENT_TIMESTAMP"` UpdateTime *Timestamp `protobuf:"bytes,3,opt,name=update_time,json=updateTime,proto3" json:"update_time,omitempty" gorm:"default:CURRENT_TIMESTAMP"` // name is the optional friendly name used to // access the Scope via an API // @inject_tag: `gorm:"default:null"` Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty" gorm:"default:null"` // @inject_tag: `gorm:"default:null"` Model string `protobuf:"bytes,6,opt,name=model,proto3" json:"model,omitempty" gorm:"default:null"` // @inject_tag: `gorm:"default:null"` Mpg int32 `protobuf:"varint,7,opt,name=mpg,proto3" json:"mpg,omitempty" gorm:"default:null"` // contains filtered or unexported fields }
TestCar car model
func (*StoreTestCar) Descriptor
deprecated
func (*StoreTestCar) Descriptor() ([]byte, []int)
Deprecated: Use StoreTestCar.ProtoReflect.Descriptor instead.
func (*StoreTestCar) GetCreateTime ¶
func (x *StoreTestCar) GetCreateTime() *Timestamp
func (*StoreTestCar) GetModel ¶
func (x *StoreTestCar) GetModel() string
func (*StoreTestCar) GetMpg ¶
func (x *StoreTestCar) GetMpg() int32
func (*StoreTestCar) GetName ¶
func (x *StoreTestCar) GetName() string
func (*StoreTestCar) GetPublicId ¶
func (x *StoreTestCar) GetPublicId() string
func (*StoreTestCar) GetUpdateTime ¶
func (x *StoreTestCar) GetUpdateTime() *Timestamp
func (*StoreTestCar) ProtoMessage ¶
func (*StoreTestCar) ProtoMessage()
func (*StoreTestCar) ProtoReflect ¶
func (x *StoreTestCar) ProtoReflect() protoreflect.Message
func (*StoreTestCar) Reset ¶
func (x *StoreTestCar) Reset()
func (*StoreTestCar) String ¶
func (x *StoreTestCar) String() string
type StoreTestRental ¶
type StoreTestRental struct { // @inject_tag: `gorm:"primaryKey"` UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty" gorm:"primaryKey"` // @inject_tag: `gorm:"primaryKey"` CarId string `protobuf:"bytes,2,opt,name=car_id,json=carId,proto3" json:"car_id,omitempty" gorm:"primaryKey"` // create_time from the RDBMS // @inject_tag: `gorm:"default:CURRENT_TIMESTAMP"` CreateTime *Timestamp `protobuf:"bytes,3,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty" gorm:"default:CURRENT_TIMESTAMP"` // update_time from the RDBMS // @inject_tag: `gorm:"default:CURRENT_TIMESTAMP"` UpdateTime *Timestamp `protobuf:"bytes,4,opt,name=update_time,json=updateTime,proto3" json:"update_time,omitempty" gorm:"default:CURRENT_TIMESTAMP"` // name is the optional friendly name used to // access the rental via an API // @inject_tag: `gorm:"default:null"` Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty" gorm:"default:null"` // @inject_tag: `gorm:"default:null"` Version uint32 `protobuf:"varint,6,opt,name=version,proto3" json:"version,omitempty" gorm:"default:null"` // contains filtered or unexported fields }
TestRental for test rental model
func (*StoreTestRental) Descriptor
deprecated
func (*StoreTestRental) Descriptor() ([]byte, []int)
Deprecated: Use StoreTestRental.ProtoReflect.Descriptor instead.
func (*StoreTestRental) GetCarId ¶
func (x *StoreTestRental) GetCarId() string
func (*StoreTestRental) GetCreateTime ¶
func (x *StoreTestRental) GetCreateTime() *Timestamp
func (*StoreTestRental) GetName ¶
func (x *StoreTestRental) GetName() string
func (*StoreTestRental) GetUpdateTime ¶
func (x *StoreTestRental) GetUpdateTime() *Timestamp
func (*StoreTestRental) GetUserId ¶
func (x *StoreTestRental) GetUserId() string
func (*StoreTestRental) GetVersion ¶
func (x *StoreTestRental) GetVersion() uint32
func (*StoreTestRental) ProtoMessage ¶
func (*StoreTestRental) ProtoMessage()
func (*StoreTestRental) ProtoReflect ¶
func (x *StoreTestRental) ProtoReflect() protoreflect.Message
func (*StoreTestRental) Reset ¶
func (x *StoreTestRental) Reset()
func (*StoreTestRental) String ¶
func (x *StoreTestRental) String() string
type StoreTestScooter ¶
type StoreTestScooter struct { // private_id is the used to access scooter, but not intended to be available // via the API // @inject_tag: `gorm:"primaryKey"` PrivateId string `protobuf:"bytes,1,opt,name=private_id,json=privateId,proto3" json:"private_id,omitempty" gorm:"primaryKey"` // create_time from the RDBMS // @inject_tag: `gorm:"default:CURRENT_TIMESTAMP"` CreateTime *Timestamp `protobuf:"bytes,2,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty" gorm:"default:CURRENT_TIMESTAMP"` // update_time from the RDBMS // @inject_tag: `gorm:"default:CURRENT_TIMESTAMP"` UpdateTime *Timestamp `protobuf:"bytes,3,opt,name=update_time,json=updateTime,proto3" json:"update_time,omitempty" gorm:"default:CURRENT_TIMESTAMP"` // @inject_tag: `gorm:"default:null"` Model string `protobuf:"bytes,4,opt,name=model,proto3" json:"model,omitempty" gorm:"default:null"` // @inject_tag: `gorm:"default:null"` Mpg int32 `protobuf:"varint,5,opt,name=mpg,proto3" json:"mpg,omitempty" gorm:"default:null"` // @inject_tag: `gorm:"-"` ReadOnlyField string `protobuf:"bytes,6,opt,name=read_only_field,json=readOnlyField,proto3" json:"read_only_field,omitempty" gorm:"-"` // contains filtered or unexported fields }
StoreTestScooter used in the db tests only and provides a resource with a private id.
func (*StoreTestScooter) Descriptor
deprecated
func (*StoreTestScooter) Descriptor() ([]byte, []int)
Deprecated: Use StoreTestScooter.ProtoReflect.Descriptor instead.
func (*StoreTestScooter) GetCreateTime ¶
func (x *StoreTestScooter) GetCreateTime() *Timestamp
func (*StoreTestScooter) GetModel ¶
func (x *StoreTestScooter) GetModel() string
func (*StoreTestScooter) GetMpg ¶
func (x *StoreTestScooter) GetMpg() int32
func (*StoreTestScooter) GetPrivateId ¶
func (x *StoreTestScooter) GetPrivateId() string
func (*StoreTestScooter) GetReadOnlyField ¶
func (x *StoreTestScooter) GetReadOnlyField() string
func (*StoreTestScooter) GetUpdateTime ¶
func (x *StoreTestScooter) GetUpdateTime() *Timestamp
func (*StoreTestScooter) ProtoMessage ¶
func (*StoreTestScooter) ProtoMessage()
func (*StoreTestScooter) ProtoReflect ¶
func (x *StoreTestScooter) ProtoReflect() protoreflect.Message
func (*StoreTestScooter) Reset ¶
func (x *StoreTestScooter) Reset()
func (*StoreTestScooter) String ¶
func (x *StoreTestScooter) String() string
type StoreTestUser ¶
type StoreTestUser struct { // public_id is the used to access the user via an API // @inject_tag: gorm:"primaryKey;default:null" PublicId string `protobuf:"bytes,4,opt,name=public_id,json=publicId,proto3" json:"public_id,omitempty" gorm:"primaryKey;default:null"` // create_time from the RDBMS // @inject_tag: `gorm:"default:CURRENT_TIMESTAMP"` CreateTime *Timestamp `protobuf:"bytes,2,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty" gorm:"default:CURRENT_TIMESTAMP"` // update_time from the RDBMS // @inject_tag: `gorm:"default:CURRENT_TIMESTAMP"` UpdateTime *Timestamp `protobuf:"bytes,3,opt,name=update_time,json=updateTime,proto3" json:"update_time,omitempty" gorm:"default:CURRENT_TIMESTAMP"` // name is the optional friendly name used to // access the user via an API // @inject_tag: `gorm:"default:null"` Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty" gorm:"default:null"` // @inject_tag: `gorm:"default:null"` PhoneNumber string `protobuf:"bytes,6,opt,name=phone_number,json=phoneNumber,proto3" json:"phone_number,omitempty" gorm:"default:null"` // @inject_tag: `gorm:"default:null"` Email string `protobuf:"bytes,7,opt,name=email,proto3" json:"email,omitempty" gorm:"default:null"` // @inject_tag: `gorm:"default:null"` Version uint32 `protobuf:"varint,8,opt,name=version,proto3" json:"version,omitempty" gorm:"default:null"` // contains filtered or unexported fields }
TestUser model
func (*StoreTestUser) Descriptor
deprecated
func (*StoreTestUser) Descriptor() ([]byte, []int)
Deprecated: Use StoreTestUser.ProtoReflect.Descriptor instead.
func (*StoreTestUser) GetCreateTime ¶
func (x *StoreTestUser) GetCreateTime() *Timestamp
func (*StoreTestUser) GetEmail ¶
func (x *StoreTestUser) GetEmail() string
func (*StoreTestUser) GetName ¶
func (x *StoreTestUser) GetName() string
func (*StoreTestUser) GetPhoneNumber ¶
func (x *StoreTestUser) GetPhoneNumber() string
func (*StoreTestUser) GetPublicId ¶
func (x *StoreTestUser) GetPublicId() string
func (*StoreTestUser) GetUpdateTime ¶
func (x *StoreTestUser) GetUpdateTime() *Timestamp
func (*StoreTestUser) GetVersion ¶
func (x *StoreTestUser) GetVersion() uint32
func (*StoreTestUser) ProtoMessage ¶
func (*StoreTestUser) ProtoMessage()
func (*StoreTestUser) ProtoReflect ¶
func (x *StoreTestUser) ProtoReflect() protoreflect.Message
func (*StoreTestUser) Reset ¶
func (x *StoreTestUser) Reset()
func (*StoreTestUser) String ¶
func (x *StoreTestUser) String() string
type TestCar ¶
type TestCar struct { *StoreTestCar // contains filtered or unexported fields }
func NewTestCar ¶
func (*TestCar) SetTableName ¶
type TestRental ¶
type TestRental struct { *StoreTestRental // contains filtered or unexported fields }
func NewTestRental ¶
func NewTestRental(userId, carId string) (*TestRental, error)
func (*TestRental) Clone ¶
func (t *TestRental) Clone() interface{}
Clone is useful when you're retrying transactions and you need to send the user several times
func (*TestRental) SetTableName ¶
func (r *TestRental) SetTableName(name string)
func (*TestRental) TableName ¶
func (r *TestRental) TableName() string
type TestScooter ¶
type TestScooter struct { *StoreTestScooter // contains filtered or unexported fields }
func NewTestScooter ¶
func NewTestScooter() (*TestScooter, error)
func (*TestScooter) Clone ¶
func (t *TestScooter) Clone() interface{}
func (*TestScooter) SetTableName ¶
func (t *TestScooter) SetTableName(name string)
func (*TestScooter) TableName ¶
func (t *TestScooter) TableName() string
type TestUser ¶
type TestUser struct { *StoreTestUser // contains filtered or unexported fields }
func AllocTestUser ¶
func AllocTestUser() TestUser
func NewTestUser ¶
func (*TestUser) Clone ¶
func (u *TestUser) Clone() interface{}
Clone is useful when you're retrying transactions and you need to send the user several times
func (*TestUser) SetTableName ¶
type TestWithAfterCreate ¶
type TestWithAfterCreate struct{}
func (*TestWithAfterCreate) AfterCreate ¶
func (t *TestWithAfterCreate) AfterCreate(_ *gorm.DB) error
type TestWithAfterDelete ¶
type TestWithAfterDelete struct{}
func (*TestWithAfterDelete) AfterDelete ¶
func (t *TestWithAfterDelete) AfterDelete(_ *gorm.DB) error
type TestWithAfterFind ¶
type TestWithAfterFind struct{}
type TestWithAfterSave ¶
type TestWithAfterSave struct{}
type TestWithAfterUpdate ¶
type TestWithAfterUpdate struct{}
func (*TestWithAfterUpdate) AfterUpdate ¶
func (t *TestWithAfterUpdate) AfterUpdate(_ *gorm.DB) error
type TestWithBeforeCreate ¶
type TestWithBeforeCreate struct{}
func (*TestWithBeforeCreate) BeforeCreate ¶
func (t *TestWithBeforeCreate) BeforeCreate(_ *gorm.DB) error
type TestWithBeforeDelete ¶
type TestWithBeforeDelete struct{}
func (*TestWithBeforeDelete) BeforeDelete ¶
func (t *TestWithBeforeDelete) BeforeDelete(_ *gorm.DB) error
type TestWithBeforeSave ¶
type TestWithBeforeSave struct{}
func (*TestWithBeforeSave) BeforeSave ¶
func (t *TestWithBeforeSave) BeforeSave(_ *gorm.DB) error
type TestWithBeforeUpdate ¶
type TestWithBeforeUpdate struct{}
func (*TestWithBeforeUpdate) BeforeUpdate ¶
func (t *TestWithBeforeUpdate) BeforeUpdate(_ *gorm.DB) error
type Timestamp ¶
type Timestamp struct { Timestamp *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // contains filtered or unexported fields }
Timestamp for storage messages. We've defined a new local type wrapper of google.protobuf.Timestamp so we can implement sql.Scanner and sql.Valuer interfaces. See: https://golang.org/pkg/database/sql/#Scanner https://golang.org/pkg/database/sql/driver/#Valuer
func (*Timestamp) Descriptor
deprecated
func (*Timestamp) GetTimestamp ¶
func (x *Timestamp) GetTimestamp() *timestamppb.Timestamp
func (*Timestamp) GormDataType ¶
GormDataType gorm common data type (required)
func (*Timestamp) ProtoMessage ¶
func (*Timestamp) ProtoMessage()
func (*Timestamp) ProtoReflect ¶
func (x *Timestamp) ProtoReflect() protoreflect.Message