From 331f024c2bbc994e6c91cda87594b95452d5a00c Mon Sep 17 00:00:00 2001 From: Jim Lambert Date: Tue, 14 Apr 2020 14:36:57 -0400 Subject: [PATCH] db test protos --- internal/db/db_test/db.go | 111 ++++++ internal/db/db_test/db_test.pb.go | 593 ++++++++++++++++++++++++++++++ internal/db/db_test/db_test.proto | 86 +++++ 3 files changed, 790 insertions(+) create mode 100644 internal/db/db_test/db.go create mode 100644 internal/db/db_test/db_test.pb.go create mode 100644 internal/db/db_test/db_test.proto diff --git a/internal/db/db_test/db.go b/internal/db/db_test/db.go new file mode 100644 index 0000000000..de831c4fe4 --- /dev/null +++ b/internal/db/db_test/db.go @@ -0,0 +1,111 @@ +// Package db_test provides some helper funcs for testing db integrations +package db_test + +import ( + "github.com/hashicorp/vault/sdk/helper/base62" + "github.com/jinzhu/gorm" +) + +// Init will use gorm migrations to init tables for test models +func Init(db *gorm.DB) { + db.AutoMigrate(&TestUser{}) + db.AutoMigrate(&TestCar{}) + db.AutoMigrate(&TestRental{}) +} + +// Reinit will use gorm to drop then init tables for test models +func Reinit(db *gorm.DB) { + db.DropTableIfExists(&TestUser{}) + db.DropTableIfExists(&TestCar{}) + db.DropTableIfExists(&TestRental{}) + Init(db) +} + +type TestUser struct { + StoreTestUser + table string `gorm:"-"` +} + +func NewTestUser() (*TestUser, error) { + publicId, err := base62.Random(20) + if err != nil { + return nil, err + } + return &TestUser{ + StoreTestUser: StoreTestUser{ + PublicId: publicId, + }, + }, nil +} + +func (u *TestUser) TableName() string { + if u.table != "" { + return u.table + } + return "db_test_user" +} + +func (u *TestUser) SetTableName(name string) { + if name != "" { + u.table = name + } +} + +type TestCar struct { + StoreTestCar + table string `gorm:"-"` +} + +func NewTestCar() (*TestCar, error) { + publicId, err := base62.Random(20) + if err != nil { + return nil, err + } + return &TestCar{ + StoreTestCar: StoreTestCar{ + PublicId: publicId, + }, + }, nil +} + +func (c *TestCar) TableName() string { + if c.table != "" { + return c.table + } + + return "db_test_car" +} +func (c *TestCar) SetTableName(name string) { + if name != "" { + c.table = name + } +} + +type TestRental struct { + StoreTestRental + table string `gorm:"-"` +} + +func NewTestRental() (*TestRental, error) { + publicId, err := base62.Random(20) + if err != nil { + return nil, err + } + return &TestRental{ + StoreTestRental: StoreTestRental{ + PublicId: publicId, + }, + }, nil +} +func (r *TestRental) TableName() string { + if r.table != "" { + return r.table + } + + return "db_test_rental" +} +func (r *TestRental) SetTableName(name string) { + if name != "" { + r.table = name + } +} diff --git a/internal/db/db_test/db_test.pb.go b/internal/db/db_test/db_test.pb.go new file mode 100644 index 0000000000..b6d4e3a7b6 --- /dev/null +++ b/internal/db/db_test/db_test.pb.go @@ -0,0 +1,593 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.20.1 +// protoc v3.11.4 +// source: db_test/db_test.proto + +// define a test proto package + +package db_test + +import ( + proto "github.com/golang/protobuf/proto" + timestamp "github.com/golang/protobuf/ptypes/timestamp" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + +// Timestamp for oplog messages +type Timestamp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Timestamp *timestamp.Timestamp `protobuf:"bytes,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` +} + +func (x *Timestamp) Reset() { + *x = Timestamp{} + if protoimpl.UnsafeEnabled { + mi := &file_db_test_db_test_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Timestamp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Timestamp) ProtoMessage() {} + +func (x *Timestamp) ProtoReflect() protoreflect.Message { + mi := &file_db_test_db_test_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Timestamp.ProtoReflect.Descriptor instead. +func (*Timestamp) Descriptor() ([]byte, []int) { + return file_db_test_db_test_proto_rawDescGZIP(), []int{0} +} + +func (x *Timestamp) GetTimestamp() *timestamp.Timestamp { + if x != nil { + return x.Timestamp + } + return nil +} + +// TestUser for gorm test user model +type StoreTestUser struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // @inject_tag: gorm:"primary_key" + Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty" gorm:"primary_key"` + // 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"` + // public_id is the used to access the AssignablScope via an API + PublicId string `protobuf:"bytes,4,opt,name=public_id,json=publicId,proto3" json:"public_id,omitempty"` + // FriendlyName is the optional friendly name used to + // access the Scope via an API + // @inject_tag: `gorm:"default:null"` + FriendlyName string `protobuf:"bytes,5,opt,name=friendly_name,json=friendlyName,proto3" json:"friendly_name,omitempty" gorm:"default:null"` + Name string `protobuf:"bytes,6,opt,name=name,proto3" json:"name,omitempty"` + PhoneNumber string `protobuf:"bytes,7,opt,name=phone_number,json=phoneNumber,proto3" json:"phone_number,omitempty"` + Email string `protobuf:"bytes,8,opt,name=email,proto3" json:"email,omitempty"` +} + +func (x *StoreTestUser) Reset() { + *x = StoreTestUser{} + if protoimpl.UnsafeEnabled { + mi := &file_db_test_db_test_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StoreTestUser) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StoreTestUser) ProtoMessage() {} + +func (x *StoreTestUser) ProtoReflect() protoreflect.Message { + mi := &file_db_test_db_test_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StoreTestUser.ProtoReflect.Descriptor instead. +func (*StoreTestUser) Descriptor() ([]byte, []int) { + return file_db_test_db_test_proto_rawDescGZIP(), []int{1} +} + +func (x *StoreTestUser) GetId() uint32 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *StoreTestUser) GetCreateTime() *Timestamp { + if x != nil { + return x.CreateTime + } + return nil +} + +func (x *StoreTestUser) GetUpdateTime() *Timestamp { + if x != nil { + return x.UpdateTime + } + return nil +} + +func (x *StoreTestUser) GetPublicId() string { + if x != nil { + return x.PublicId + } + return "" +} + +func (x *StoreTestUser) GetFriendlyName() string { + if x != nil { + return x.FriendlyName + } + return "" +} + +func (x *StoreTestUser) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *StoreTestUser) GetPhoneNumber() string { + if x != nil { + return x.PhoneNumber + } + return "" +} + +func (x *StoreTestUser) GetEmail() string { + if x != nil { + return x.Email + } + return "" +} + +// TestCar for gorm test car model +type StoreTestCar struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // @inject_tag: gorm:"primary_key" + Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty" gorm:"primary_key"` + // 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"` + // public_id is the used to access the AssignablScope via an API + PublicId string `protobuf:"bytes,4,opt,name=public_id,json=publicId,proto3" json:"public_id,omitempty"` + // FriendlyName is the optional friendly name used to + // access the Scope via an API + // @inject_tag: `gorm:"default:null"` + FriendlyName string `protobuf:"bytes,5,opt,name=friendly_name,json=friendlyName,proto3" json:"friendly_name,omitempty" gorm:"default:null"` + Model string `protobuf:"bytes,6,opt,name=model,proto3" json:"model,omitempty"` + Mpg int32 `protobuf:"varint,7,opt,name=mpg,proto3" json:"mpg,omitempty"` +} + +func (x *StoreTestCar) Reset() { + *x = StoreTestCar{} + if protoimpl.UnsafeEnabled { + mi := &file_db_test_db_test_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StoreTestCar) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StoreTestCar) ProtoMessage() {} + +func (x *StoreTestCar) ProtoReflect() protoreflect.Message { + mi := &file_db_test_db_test_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StoreTestCar.ProtoReflect.Descriptor instead. +func (*StoreTestCar) Descriptor() ([]byte, []int) { + return file_db_test_db_test_proto_rawDescGZIP(), []int{2} +} + +func (x *StoreTestCar) GetId() uint32 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *StoreTestCar) GetCreateTime() *Timestamp { + if x != nil { + return x.CreateTime + } + return nil +} + +func (x *StoreTestCar) GetUpdateTime() *Timestamp { + if x != nil { + return x.UpdateTime + } + return nil +} + +func (x *StoreTestCar) GetPublicId() string { + if x != nil { + return x.PublicId + } + return "" +} + +func (x *StoreTestCar) GetFriendlyName() string { + if x != nil { + return x.FriendlyName + } + return "" +} + +func (x *StoreTestCar) GetModel() string { + if x != nil { + return x.Model + } + return "" +} + +func (x *StoreTestCar) GetMpg() int32 { + if x != nil { + return x.Mpg + } + return 0 +} + +// TestRental for gorm test rental model +type StoreTestRental struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // @inject_tag: gorm:"primary_key" + Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty" gorm:"primary_key"` + // 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"` + // public_id is the used to access the AssignablScope via an API + PublicId string `protobuf:"bytes,4,opt,name=public_id,json=publicId,proto3" json:"public_id,omitempty"` + // FriendlyName is the optional friendly name used to + // access the Scope via an API + // @inject_tag: `gorm:"default:null"` + FriendlyName string `protobuf:"bytes,5,opt,name=friendly_name,json=friendlyName,proto3" json:"friendly_name,omitempty" gorm:"default:null"` + UserId uint32 `protobuf:"varint,6,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + CarId uint32 `protobuf:"varint,7,opt,name=car_id,json=carId,proto3" json:"car_id,omitempty"` +} + +func (x *StoreTestRental) Reset() { + *x = StoreTestRental{} + if protoimpl.UnsafeEnabled { + mi := &file_db_test_db_test_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StoreTestRental) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StoreTestRental) ProtoMessage() {} + +func (x *StoreTestRental) ProtoReflect() protoreflect.Message { + mi := &file_db_test_db_test_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StoreTestRental.ProtoReflect.Descriptor instead. +func (*StoreTestRental) Descriptor() ([]byte, []int) { + return file_db_test_db_test_proto_rawDescGZIP(), []int{3} +} + +func (x *StoreTestRental) GetId() uint32 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *StoreTestRental) GetCreateTime() *Timestamp { + if x != nil { + return x.CreateTime + } + return nil +} + +func (x *StoreTestRental) GetUpdateTime() *Timestamp { + if x != nil { + return x.UpdateTime + } + return nil +} + +func (x *StoreTestRental) GetPublicId() string { + if x != nil { + return x.PublicId + } + return "" +} + +func (x *StoreTestRental) GetFriendlyName() string { + if x != nil { + return x.FriendlyName + } + return "" +} + +func (x *StoreTestRental) GetUserId() uint32 { + if x != nil { + return x.UserId + } + return 0 +} + +func (x *StoreTestRental) GetCarId() uint32 { + if x != nil { + return x.CarId + } + return 0 +} + +var File_db_test_db_test_proto protoreflect.FileDescriptor + +var file_db_test_db_test_proto_rawDesc = []byte{ + 0x0a, 0x15, 0x64, 0x62, 0x5f, 0x74, 0x65, 0x73, 0x74, 0x2f, 0x64, 0x62, 0x5f, 0x74, 0x65, 0x73, + 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x2a, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, + 0x72, 0x70, 0x2e, 0x77, 0x61, 0x74, 0x63, 0x68, 0x74, 0x6f, 0x77, 0x65, 0x72, 0x2e, 0x63, 0x6f, + 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x64, 0x62, 0x2e, 0x74, 0x65, 0x73, 0x74, + 0x2e, 0x76, 0x31, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x45, 0x0a, 0x09, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0xde, 0x02, 0x0a, 0x0d, + 0x53, 0x74, 0x6f, 0x72, 0x65, 0x54, 0x65, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x12, 0x0e, 0x0a, + 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x69, 0x64, 0x12, 0x56, 0x0a, + 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2e, 0x77, + 0x61, 0x74, 0x63, 0x68, 0x74, 0x6f, 0x77, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, + 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x64, 0x62, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, + 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x56, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, + 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x68, 0x61, 0x73, + 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2e, 0x77, 0x61, 0x74, 0x63, 0x68, 0x74, 0x6f, 0x77, 0x65, + 0x72, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x64, 0x62, 0x2e, + 0x74, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1b, 0x0a, + 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x08, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x66, 0x72, + 0x69, 0x65, 0x6e, 0x64, 0x6c, 0x79, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0c, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x6c, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, + 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x5f, 0x6e, 0x75, 0x6d, + 0x62, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x68, 0x6f, 0x6e, 0x65, + 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, + 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x22, 0xb8, 0x02, 0x0a, + 0x0c, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x54, 0x65, 0x73, 0x74, 0x43, 0x61, 0x72, 0x12, 0x0e, 0x0a, + 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x69, 0x64, 0x12, 0x56, 0x0a, + 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2e, 0x77, + 0x61, 0x74, 0x63, 0x68, 0x74, 0x6f, 0x77, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, + 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x64, 0x62, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, + 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x56, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, + 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x68, 0x61, 0x73, + 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2e, 0x77, 0x61, 0x74, 0x63, 0x68, 0x74, 0x6f, 0x77, 0x65, + 0x72, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x64, 0x62, 0x2e, + 0x74, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1b, 0x0a, + 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x08, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x66, 0x72, + 0x69, 0x65, 0x6e, 0x64, 0x6c, 0x79, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0c, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x6c, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, + 0x14, 0x0a, 0x05, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, + 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x70, 0x67, 0x18, 0x07, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x03, 0x6d, 0x70, 0x67, 0x22, 0xc3, 0x02, 0x0a, 0x0f, 0x53, 0x74, 0x6f, 0x72, + 0x65, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x6e, 0x74, 0x61, 0x6c, 0x12, 0x0e, 0x0a, 0x02, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x69, 0x64, 0x12, 0x56, 0x0a, 0x0b, 0x63, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x35, 0x2e, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2e, 0x77, 0x61, 0x74, + 0x63, 0x68, 0x74, 0x6f, 0x77, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, + 0x65, 0x72, 0x2e, 0x64, 0x62, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, + 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, + 0x69, 0x6d, 0x65, 0x12, 0x56, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, + 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x68, 0x61, 0x73, 0x68, 0x69, + 0x63, 0x6f, 0x72, 0x70, 0x2e, 0x77, 0x61, 0x74, 0x63, 0x68, 0x74, 0x6f, 0x77, 0x65, 0x72, 0x2e, + 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x64, 0x62, 0x2e, 0x74, 0x65, + 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, + 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x70, + 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, + 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x66, 0x72, 0x69, 0x65, + 0x6e, 0x64, 0x6c, 0x79, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0c, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x6c, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x17, 0x0a, + 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, + 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x15, 0x0a, 0x06, 0x63, 0x61, 0x72, 0x5f, 0x69, 0x64, + 0x18, 0x07, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x63, 0x61, 0x72, 0x49, 0x64, 0x42, 0x3d, 0x5a, + 0x3b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x73, 0x68, + 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x77, 0x61, 0x74, 0x63, 0x68, 0x74, 0x6f, 0x77, 0x65, 0x72, + 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x64, 0x62, 0x2f, 0x64, 0x62, 0x5f, + 0x74, 0x65, 0x73, 0x74, 0x3b, 0x64, 0x62, 0x5f, 0x74, 0x65, 0x73, 0x74, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_db_test_db_test_proto_rawDescOnce sync.Once + file_db_test_db_test_proto_rawDescData = file_db_test_db_test_proto_rawDesc +) + +func file_db_test_db_test_proto_rawDescGZIP() []byte { + file_db_test_db_test_proto_rawDescOnce.Do(func() { + file_db_test_db_test_proto_rawDescData = protoimpl.X.CompressGZIP(file_db_test_db_test_proto_rawDescData) + }) + return file_db_test_db_test_proto_rawDescData +} + +var file_db_test_db_test_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_db_test_db_test_proto_goTypes = []interface{}{ + (*Timestamp)(nil), // 0: hashicorp.watchtower.controller.db.test.v1.Timestamp + (*StoreTestUser)(nil), // 1: hashicorp.watchtower.controller.db.test.v1.StoreTestUser + (*StoreTestCar)(nil), // 2: hashicorp.watchtower.controller.db.test.v1.StoreTestCar + (*StoreTestRental)(nil), // 3: hashicorp.watchtower.controller.db.test.v1.StoreTestRental + (*timestamp.Timestamp)(nil), // 4: google.protobuf.Timestamp +} +var file_db_test_db_test_proto_depIdxs = []int32{ + 4, // 0: hashicorp.watchtower.controller.db.test.v1.Timestamp.timestamp:type_name -> google.protobuf.Timestamp + 0, // 1: hashicorp.watchtower.controller.db.test.v1.StoreTestUser.create_time:type_name -> hashicorp.watchtower.controller.db.test.v1.Timestamp + 0, // 2: hashicorp.watchtower.controller.db.test.v1.StoreTestUser.update_time:type_name -> hashicorp.watchtower.controller.db.test.v1.Timestamp + 0, // 3: hashicorp.watchtower.controller.db.test.v1.StoreTestCar.create_time:type_name -> hashicorp.watchtower.controller.db.test.v1.Timestamp + 0, // 4: hashicorp.watchtower.controller.db.test.v1.StoreTestCar.update_time:type_name -> hashicorp.watchtower.controller.db.test.v1.Timestamp + 0, // 5: hashicorp.watchtower.controller.db.test.v1.StoreTestRental.create_time:type_name -> hashicorp.watchtower.controller.db.test.v1.Timestamp + 0, // 6: hashicorp.watchtower.controller.db.test.v1.StoreTestRental.update_time:type_name -> hashicorp.watchtower.controller.db.test.v1.Timestamp + 7, // [7:7] is the sub-list for method output_type + 7, // [7:7] is the sub-list for method input_type + 7, // [7:7] is the sub-list for extension type_name + 7, // [7:7] is the sub-list for extension extendee + 0, // [0:7] is the sub-list for field type_name +} + +func init() { file_db_test_db_test_proto_init() } +func file_db_test_db_test_proto_init() { + if File_db_test_db_test_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_db_test_db_test_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Timestamp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_db_test_db_test_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StoreTestUser); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_db_test_db_test_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StoreTestCar); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_db_test_db_test_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StoreTestRental); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_db_test_db_test_proto_rawDesc, + NumEnums: 0, + NumMessages: 4, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_db_test_db_test_proto_goTypes, + DependencyIndexes: file_db_test_db_test_proto_depIdxs, + MessageInfos: file_db_test_db_test_proto_msgTypes, + }.Build() + File_db_test_db_test_proto = out.File + file_db_test_db_test_proto_rawDesc = nil + file_db_test_db_test_proto_goTypes = nil + file_db_test_db_test_proto_depIdxs = nil +} diff --git a/internal/db/db_test/db_test.proto b/internal/db/db_test/db_test.proto new file mode 100644 index 0000000000..9fe31ad537 --- /dev/null +++ b/internal/db/db_test/db_test.proto @@ -0,0 +1,86 @@ +syntax = "proto3"; + +// define a test proto package +package hashicorp.watchtower.controller.db.test.v1; +option go_package = "github.com/hashicorp/watchtower/internal/db/db_test;db_test"; + +import "google/protobuf/timestamp.proto"; + +// Timestamp for oplog messages +message Timestamp { + google.protobuf.Timestamp timestamp = 1; +} + +// TestUser for gorm test user model +message StoreTestUser { + // @inject_tag: gorm:"primary_key" + uint32 id = 1; + + // create_time from the RDBMS + // @inject_tag: `gorm:"default:CURRENT_TIMESTAMP"` + Timestamp create_time = 2; + + // update_time from the RDBMS + // @inject_tag: `gorm:"default:CURRENT_TIMESTAMP"` + Timestamp update_time = 3; + + // public_id is the used to access the AssignablScope via an API + string public_id = 4; + + // FriendlyName is the optional friendly name used to + // access the Scope via an API + // @inject_tag: `gorm:"default:null"` + string friendly_name = 5; + + string name = 6; + string phone_number = 7; + string email = 8; +} +// TestCar for gorm test car model +message StoreTestCar { + // @inject_tag: gorm:"primary_key" + uint32 id = 1; + + // create_time from the RDBMS + // @inject_tag: `gorm:"default:CURRENT_TIMESTAMP"` + Timestamp create_time = 2; + + // update_time from the RDBMS + // @inject_tag: `gorm:"default:CURRENT_TIMESTAMP"` + Timestamp update_time = 3; + + // public_id is the used to access the AssignablScope via an API + string public_id = 4; + + // FriendlyName is the optional friendly name used to + // access the Scope via an API + // @inject_tag: `gorm:"default:null"` + string friendly_name = 5; + + string model = 6; + int32 mpg = 7; +} +// TestRental for gorm test rental model +message StoreTestRental { + // @inject_tag: gorm:"primary_key" + uint32 id = 1; + + // create_time from the RDBMS + // @inject_tag: `gorm:"default:CURRENT_TIMESTAMP"` + Timestamp create_time = 2; + + // update_time from the RDBMS + // @inject_tag: `gorm:"default:CURRENT_TIMESTAMP"` + Timestamp update_time = 3; + + // public_id is the used to access the AssignablScope via an API + string public_id = 4; + + // FriendlyName is the optional friendly name used to + // access the Scope via an API + // @inject_tag: `gorm:"default:null"` + string friendly_name = 5; + + uint32 user_id = 6; + uint32 car_id = 7; +} \ No newline at end of file