Skip to content

Commit

Permalink
fix: unit testing cases of contrib/drivers occasionally failed by u…
Browse files Browse the repository at this point in the history
…sing now time assertion (gogf#3410)
  • Loading branch information
gqcn authored and oldme-git committed Mar 26, 2024
1 parent f3f24c5 commit 22bffda
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
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

0 comments on commit 22bffda

Please sign in to comment.