Skip to content

Commit 92863c8

Browse files
committed
test: Add CURD test cases
1 parent 5f5799c commit 92863c8

3 files changed

Lines changed: 144 additions & 48 deletions

File tree

tests/model.go

Lines changed: 48 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ type MySQLModel1 struct {
2424
Carbon2 carbon.Carbon `gorm:"column:carbon2;type:datetime;" json:"carbon2"`
2525
Carbon3 carbon.Carbon `gorm:"column:carbon3;type:timestamp;" json:"carbon3"`
2626

27+
Date1 carbon.Date `gorm:"column:date1;type:varchar(50);" json:"date1"`
28+
Date2 carbon.Date `gorm:"column:date2;type:date;" json:"date2"`
29+
Date3 carbon.Date `gorm:"column:date3;type:timestamp;" json:"date3"`
30+
31+
Time1 carbon.Time `gorm:"column:time1;type:varchar(50);" json:"time1"`
32+
Time2 carbon.Time `gorm:"column:time2;type:time;" json:"time2"`
33+
Time3 carbon.Time `gorm:"column:time3;type:timestamp;" json:"time3"`
34+
2735
DateTime1 carbon.DateTime `gorm:"column:date_time1;type:varchar(50);" json:"date_time1"`
2836
DateTime2 carbon.DateTime `gorm:"column:date_time2;type:datetime;" json:"date_time2"`
2937
DateTime3 carbon.DateTime `gorm:"column:date_time3;type:timestamp;" json:"date_time3"`
@@ -38,8 +46,8 @@ type MySQLModel1 struct {
3846

3947
Timestamp1 carbon.Timestamp `gorm:"column:timestamp1;type:bigint;" json:"timestamp1"`
4048

41-
CreatedAt carbon.DateTime `gorm:"autoCreateTime;column:created_at;type:timestamp;" json:"-"`
42-
UpdatedAt carbon.DateTime `gorm:"autoUpdateTime;column:updated_at;type:timestamp;" json:"-"`
49+
CreatedAt carbon.DateTime `gorm:"column:created_at;type:timestamp;" json:"-"`
50+
UpdatedAt carbon.DateTime `gorm:"column:updated_at;type:timestamp;" json:"-"`
4351
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime;" json:"-"`
4452
}
4553

@@ -54,6 +62,14 @@ type MySQLModel2 struct {
5462
Carbon2 *carbon.Carbon `gorm:"column:carbon2;type:datetime;" json:"carbon2"`
5563
Carbon3 *carbon.Carbon `gorm:"column:carbon3;type:timestamp;" json:"carbon3"`
5664

65+
Date1 *carbon.Date `gorm:"column:date1;type:varchar(50);" json:"date1"`
66+
Date2 *carbon.Date `gorm:"column:date2;type:date;" json:"date2"`
67+
Date3 *carbon.Date `gorm:"column:date3;type:timestamp;" json:"date3"`
68+
69+
Time1 *carbon.Time `gorm:"column:time1;type:varchar(50);" json:"time1"`
70+
Time2 *carbon.Time `gorm:"column:time2;type:time;" json:"time2"`
71+
Time3 *carbon.Time `gorm:"column:time3;type:timestamp;" json:"time3"`
72+
5773
DateTime1 *carbon.DateTime `gorm:"column:date_time1;type:varchar(50);" json:"date_time1"`
5874
DateTime2 *carbon.DateTime `gorm:"column:date_time2;type:datetime;" json:"date_time2"`
5975
DateTime3 *carbon.DateTime `gorm:"column:date_time3;type:timestamp;" json:"date_time3"`
@@ -68,8 +84,8 @@ type MySQLModel2 struct {
6884

6985
Timestamp1 *carbon.Timestamp `gorm:"column:timestamp1;type:bigint;" json:"timestamp1"`
7086

71-
CreatedAt *carbon.DateTime `gorm:"autoCreateTime;column:created_at;type:timestamp;" json:"-"`
72-
UpdatedAt *carbon.DateTime `gorm:"autoUpdateTime;column:updated_at;type:timestamp;" json:"-"`
87+
CreatedAt *carbon.DateTime `gorm:"column:created_at;type:timestamp;" json:"-"`
88+
UpdatedAt *carbon.DateTime `gorm:"column:updated_at;type:timestamp;" json:"-"`
7389
DeletedAt *gorm.DeletedAt `gorm:"column:deleted_at;type:datetime;" json:"-"`
7490
}
7591

@@ -80,28 +96,28 @@ func (MySQLModel2) TableName() string {
8096
type PgSQLModel1 struct {
8197
ID uint64 `json:"-" gorm:"column:id;primaryKey"`
8298

83-
Carbon1 carbon.Carbon `gorm:"type:timestamp;" json:"carbon1"`
84-
Carbon2 carbon.Carbon `gorm:"type:timestamptz;" json:"carbon2"`
99+
Carbon1 carbon.Carbon `gorm:"column:carbon1;type:timestamp without time zone;" json:"carbon1"`
100+
Carbon2 carbon.Carbon `gorm:"column:carbon2;type:timestamp with time zone;" json:"carbon2"`
85101

86-
Date1 carbon.Date `gorm:"type:date;" json:"date1"`
102+
Date1 carbon.Date `gorm:"column:date1;type:date;" json:"date1"`
87103

88-
Time1 carbon.Time `gorm:"type:time;" json:"time1"`
89-
Time2 carbon.Time `gorm:"type:timetz;" json:"time2"`
104+
Time1 carbon.Time `gorm:"column:time1;type:time without time zone;" json:"time1"`
105+
Time2 carbon.Time `gorm:"column:time2;type:time with time zone;" json:"time2"`
90106

91-
DateTime1 carbon.DateTime `gorm:"type:timestamp;" json:"date_time1"`
92-
DateTime2 carbon.DateTime `gorm:"type:timestamptz;" json:"date_time2"`
107+
DateTime1 carbon.DateTime `gorm:"column:date_time1;type:timestamp without time zone;" json:"date_time1"`
108+
DateTime2 carbon.DateTime `gorm:"column:date_time2;type:timestamp with time zone;" json:"date_time2"`
93109

94-
RFC3339Layout1 carbon.LayoutType[RFC3339Layout] `gorm:"column:rfc3339_layout1;type:timestamp;" json:"rfc3339_layout1"`
95-
RFC3339Layout2 carbon.LayoutType[RFC3339Layout] `gorm:"column:rfc3339_layout2;type:timestamptz;" json:"rfc3339_layout2"`
110+
RFC3339Layout1 carbon.LayoutType[RFC3339Layout] `gorm:"column:rfc3339_layout1;type:timestamp without time zone;" json:"rfc3339_layout1"`
111+
RFC3339Layout2 carbon.LayoutType[RFC3339Layout] `gorm:"column:rfc3339_layout2;type:timestamp with time zone;" json:"rfc3339_layout2"`
96112

97-
ISO8601Format1 carbon.FormatType[ISO8601Format] `gorm:"column:iso8601_format1;type:timestamp;" json:"iso8601_format1"`
98-
ISO8601Format2 carbon.FormatType[ISO8601Format] `gorm:"column:iso8601_format2;type:timestamptz;" json:"iso8601_format2"`
113+
ISO8601Format1 carbon.FormatType[ISO8601Format] `gorm:"column:iso8601_format1;type:timestamp without time zone;" json:"iso8601_format1"`
114+
ISO8601Format2 carbon.FormatType[ISO8601Format] `gorm:"column:iso8601_format2;type:timestamp with time zone;" json:"iso8601_format2"`
99115

100116
Timestamp1 carbon.Timestamp `gorm:"column:timestamp1;type:int4;" json:"timestamp1"`
101117

102-
CreatedAt carbon.DateTime `gorm:"autoCreateTime;column:created_at;type:timestamptz;" json:"-"`
103-
UpdatedAt carbon.DateTime `gorm:"autoUpdateTime;column:updated_at;type:timestamptz;" json:"-"`
104-
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamptz;" json:"-"`
118+
CreatedAt carbon.DateTime `gorm:"column:created_at;type:timestamp with time zone;" json:"-"`
119+
UpdatedAt carbon.DateTime `gorm:"column:updated_at;type:timestamp with time zone;" json:"-"`
120+
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp with time zone;" json:"-"`
105121
}
106122

107123
func (PgSQLModel1) TableName() string {
@@ -111,28 +127,28 @@ func (PgSQLModel1) TableName() string {
111127
type PgSQLModel2 struct {
112128
ID uint64 `json:"-" gorm:"column:id;primaryKey"`
113129

114-
Carbon1 *carbon.Carbon `gorm:"type:timestamp;" json:"carbon1"`
115-
Carbon2 *carbon.Carbon `gorm:"type:timestamptz;" json:"carbon2"`
130+
Carbon1 *carbon.Carbon `gorm:"column:carbon1;type:timestamp without time zone;" json:"carbon1"`
131+
Carbon2 *carbon.Carbon `gorm:"column:carbon2;type:timestamp with time zone;" json:"carbon2"`
116132

117-
Date1 *carbon.Date `gorm:"type:date;" json:"date1"`
133+
Date1 *carbon.Date `gorm:"column:date1;type:date;" json:"date1"`
118134

119-
Time1 *carbon.Time `gorm:"type:time;" json:"time1"`
120-
Time2 *carbon.Time `gorm:"type:timetz;" json:"time2"`
135+
Time1 *carbon.Time `gorm:"column:time1;type:time without time zone;" json:"time1"`
136+
Time2 *carbon.Time `gorm:"column:time2;type:time with time zone;" json:"time2"`
121137

122-
DateTime1 *carbon.DateTime `gorm:"type:timestamp;" json:"date_time1"`
123-
DateTime2 *carbon.DateTime `gorm:"type:timestamptz;" json:"date_time2"`
138+
DateTime1 *carbon.DateTime `gorm:"column:date_time1;type:timestamp without time zone;" json:"date_time1"`
139+
DateTime2 *carbon.DateTime `gorm:"column:date_time2;type:timestamp with time zone;" json:"date_time2"`
124140

125-
RFC3339Layout1 *carbon.LayoutType[RFC3339Layout] `gorm:"column:rfc3339_layout1;type:timestamp;" json:"rfc3339_layout1"`
126-
RFC3339Layout2 *carbon.LayoutType[RFC3339Layout] `gorm:"column:rfc3339_layout2;type:timestamptz;" json:"rfc3339_layout2"`
141+
RFC3339Layout1 *carbon.LayoutType[RFC3339Layout] `gorm:"column:rfc3339_layout1;type:timestamp without time zone;" json:"rfc3339_layout1"`
142+
RFC3339Layout2 *carbon.LayoutType[RFC3339Layout] `gorm:"column:rfc3339_layout2;type:timestamp with time zone;" json:"rfc3339_layout2"`
127143

128-
ISO8601Format1 *carbon.FormatType[ISO8601Format] `gorm:"column:iso8601_format1;type:timestamp;" json:"iso8601_format1"`
129-
ISO8601Format2 *carbon.FormatType[ISO8601Format] `gorm:"column:iso8601_format2;type:timestamptz;" json:"iso8601_format2"`
144+
ISO8601Format1 *carbon.FormatType[ISO8601Format] `gorm:"column:iso8601_format1;type:timestamp without time zone;" json:"iso8601_format1"`
145+
ISO8601Format2 *carbon.FormatType[ISO8601Format] `gorm:"column:iso8601_format2;type:timestamp with time zone;" json:"iso8601_format2"`
130146

131147
Timestamp1 *carbon.Timestamp `gorm:"column:timestamp1;type:int4;" json:"timestamp1"`
132148

133-
CreatedAt *carbon.DateTime `gorm:"autoCreateTime;column:created_at;type:timestamptz;" json:"-"`
134-
UpdatedAt *carbon.DateTime `gorm:"autoUpdateTime;column:updated_at;type:timestamptz;" json:"-"`
135-
DeletedAt *gorm.DeletedAt `gorm:"column:deleted_at;type:timestamptz;" json:"-"`
149+
CreatedAt *carbon.DateTime `gorm:"column:created_at;type:timestamp with time zone;" json:"-"`
150+
UpdatedAt *carbon.DateTime `gorm:"column:updated_at;type:timestamp with time zone;" json:"-"`
151+
DeletedAt *gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp with time zone;" json:"-"`
136152
}
137153

138154
func (PgSQLModel2) TableName() string {

0 commit comments

Comments
 (0)