Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: unit testing cases of contrib/drivers occasionally failed by using now time assertion #3410

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion contrib/drivers/mssql/mssql_z_unit_basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func Test_DB_Insert(t *testing.T) {
Nickname string `gconv:"nickname"`
CreateTime *gtime.Time `json:"create_time"`
}
timeNow := gtime.Now()
timeNow := gtime.New("2024-10-01 12:01:01")
result, err = db.Insert(ctx, table, User{
Id: 3,
Passport: "user_3",
Expand Down
10 changes: 5 additions & 5 deletions contrib/drivers/mysql/mysql_z_unit_core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func Test_DB_Insert(t *testing.T) {
Nickname string `gconv:"nickname"`
CreateTime string `json:"create_time"`
}
timeStr := gtime.Now().String()
timeStr := gtime.New("2024-10-01 12:01:01").String()
result, err = db.Insert(ctx, table, User{
Id: 3,
Passport: "user_3",
Expand All @@ -149,7 +149,7 @@ func Test_DB_Insert(t *testing.T) {
t.Assert(one["create_time"].GTime().String(), timeStr)

// *struct
timeStr = gtime.Now().String()
timeStr = gtime.New("2024-10-01 12:01:01").String()
result, err = db.Insert(ctx, table, &User{
Id: 4,
Passport: "t4",
Expand All @@ -170,7 +170,7 @@ func Test_DB_Insert(t *testing.T) {
t.Assert(one["create_time"].GTime().String(), timeStr)

// batch with Insert
timeStr = gtime.Now().String()
timeStr = gtime.New("2024-10-01 12:01:01").String()
r, err := db.Insert(ctx, table, g.Slice{
g.Map{
"id": 200,
Expand Down Expand Up @@ -487,7 +487,7 @@ func Test_DB_Save(t *testing.T) {
defer dropTable(table)

gtest.C(t, func(t *gtest.T) {
timeStr := gtime.Now().String()
timeStr := gtime.New("2024-10-01 12:01:01").String()
_, err := db.Save(ctx, table, g.Map{
"id": 1,
"passport": "t1",
Expand All @@ -512,7 +512,7 @@ func Test_DB_Replace(t *testing.T) {
defer dropTable(table)

gtest.C(t, func(t *gtest.T) {
timeStr := gtime.Now().String()
timeStr := gtime.New("2024-10-01 12:01:01").String()
_, err := db.Replace(ctx, table, g.Map{
"id": 1,
"passport": "t1",
Expand Down
6 changes: 3 additions & 3 deletions contrib/drivers/oracle/oracle_z_unit_basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func Test_DB_Insert(t *testing.T) {
Salary float64 `gconv:"SALARY"`
CreateTime string `json:"CREATE_TIME"`
}
timeStr := gtime.Now().String()
timeStr := gtime.New("2024-10-01 12:01:01").String()
result, err = db.Insert(ctx, table, User{
Id: 3,
Passport: "user_3",
Expand All @@ -243,7 +243,7 @@ func Test_DB_Insert(t *testing.T) {
t.Assert(one["CREATE_TIME"].GTime().String(), timeStr)

// *struct
timeStr = gtime.Now().String()
timeStr = gtime.New("2024-10-01 12:01:01").String()
result, err = db.Insert(ctx, table, &User{
Id: 4,
Passport: "t4",
Expand All @@ -266,7 +266,7 @@ func Test_DB_Insert(t *testing.T) {
t.Assert(one["CREATE_TIME"].GTime().String(), timeStr)

// batch with Insert
timeStr = gtime.Now().String()
timeStr = gtime.New("2024-10-01 12:01:01").String()
r, err := db.Insert(ctx, table, g.Slice{
g.Map{
"ID": 200,
Expand Down
8 changes: 4 additions & 4 deletions contrib/drivers/sqlite/sqlite_z_unit_core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func Test_DB_Insert(t *testing.T) {
Nickname string `gconv:"nickname"`
CreateTime string `json:"create_time"`
}
timeStr := gtime.Now().String()
timeStr := gtime.New("2024-10-01 12:01:01").String()
result, err = db.Insert(ctx, table, User{
Id: 3,
Passport: "user_3",
Expand All @@ -162,7 +162,7 @@ func Test_DB_Insert(t *testing.T) {
t.Assert(one["create_time"].GTime().String(), timeStr)

// *struct
timeStr = gtime.Now().String()
timeStr = gtime.New("2024-10-01 12:01:01").String()
result, err = db.Insert(ctx, table, &User{
Id: 4,
Passport: "t4",
Expand All @@ -183,7 +183,7 @@ func Test_DB_Insert(t *testing.T) {
t.Assert(one["create_time"].GTime().String(), timeStr)

// batch with Insert
timeStr = gtime.Now().String()
timeStr = gtime.New("2024-10-01 12:01:01").String()
r, err := db.Insert(ctx, table, g.Slice{
g.Map{
"id": 200,
Expand Down Expand Up @@ -449,7 +449,7 @@ func Test_DB_Replace(t *testing.T) {
defer dropTable(table)

gtest.C(t, func(t *gtest.T) {
timeStr := gtime.Now().String()
timeStr := gtime.New("2024-10-01 12:01:01").String()
_, err := db.Replace(ctx, table, g.Map{
"id": 1,
"passport": "t1",
Expand Down
8 changes: 4 additions & 4 deletions contrib/drivers/sqlitecgo/sqlitecgo_z_unit_core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func Test_DB_Insert(t *testing.T) {
Nickname string `gconv:"nickname"`
CreateTime string `json:"create_time"`
}
timeStr := gtime.Now().String()
timeStr := gtime.New("2024-10-01 12:01:01").String()
result, err = db.Insert(ctx, table, User{
Id: 3,
Passport: "user_3",
Expand All @@ -162,7 +162,7 @@ func Test_DB_Insert(t *testing.T) {
t.Assert(one["create_time"].GTime().String(), timeStr)

// *struct
timeStr = gtime.Now().String()
timeStr = gtime.New("2024-10-01 12:01:01").String()
result, err = db.Insert(ctx, table, &User{
Id: 4,
Passport: "t4",
Expand All @@ -183,7 +183,7 @@ func Test_DB_Insert(t *testing.T) {
t.Assert(one["create_time"].GTime().String(), timeStr)

// batch with Insert
timeStr = gtime.Now().String()
timeStr = gtime.New("2024-10-01 12:01:01").String()
r, err := db.Insert(ctx, table, g.Slice{
g.Map{
"id": 200,
Expand Down Expand Up @@ -449,7 +449,7 @@ func Test_DB_Replace(t *testing.T) {
defer dropTable(table)

gtest.C(t, func(t *gtest.T) {
timeStr := gtime.Now().String()
timeStr := gtime.New("2024-10-01 12:01:01").String()
_, err := db.Replace(ctx, table, g.Map{
"id": 1,
"passport": "t1",
Expand Down