Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
demoManito committed Oct 20, 2023
1 parent 73a5cbe commit 6508f28
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tests/scanner_valuer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ func TestGORMValuer(t *testing.T) {
Point: Point{X: 100, Y: 100},
}).Statement

if !regexp.MustCompile(`UPDATE .user_with_points. SET .name.=.+,.point.=ST_PointFromText\(.+\)`).MatchString(stmt.SQL.String()) {
if !regexp.MustCompile(`UPDATE .user_with_points. SET .name. = .+, .point. = ST_PointFromText\(.+\)`).MatchString(stmt.SQL.String()) {
t.Errorf("update with sql.Expr, but got %v", stmt.SQL.String())
}

Expand Down
2 changes: 1 addition & 1 deletion tests/soft_delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestSoftDelete(t *testing.T) {
}

sql := DB.Session(&gorm.Session{DryRun: true}).Delete(&user).Statement.SQL.String()
if !regexp.MustCompile(`UPDATE .users. SET .deleted_at.=.* WHERE .users.\..id. = .* AND .users.\..deleted_at. IS NULL`).MatchString(sql) {
if !regexp.MustCompile(`UPDATE .users. SET .deleted_at. = .* WHERE .users.\..id. = .* AND .users.\..deleted_at. IS NULL`).MatchString(sql) {
t.Fatalf("invalid sql generated, got %v", sql)
}

Expand Down
8 changes: 4 additions & 4 deletions tests/sql_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,25 +198,25 @@ func TestExplainSQL(t *testing.T) {

stmt := dryRunDB.Model(&user).Where("id = ?", 1).Updates(map[string]interface{}{"age": ageInt(8)}).Statement
sql := DB.Dialector.Explain(stmt.SQL.String(), stmt.Vars...)
if !regexp.MustCompile(`.*age.*=8,`).MatchString(sql) {
if !regexp.MustCompile(`.*age.* = 8, `).MatchString(sql) {
t.Errorf("Failed to generate sql, got %v", sql)
}

stmt = dryRunDB.Model(&user).Where("id = ?", 1).Updates(map[string]interface{}{"age": ageUint64(10241024)}).Statement
sql = DB.Dialector.Explain(stmt.SQL.String(), stmt.Vars...)
if !regexp.MustCompile(`.*age.*=10241024,`).MatchString(sql) {
if !regexp.MustCompile(`.*age.* = 10241024, `).MatchString(sql) {
t.Errorf("Failed to generate sql, got %v", sql)
}

stmt = dryRunDB.Model(&user).Where("id = ?", 1).Updates(map[string]interface{}{"age": ageBool(false)}).Statement
sql = DB.Dialector.Explain(stmt.SQL.String(), stmt.Vars...)
if !regexp.MustCompile(`.*age.*=false,`).MatchString(sql) {
if !regexp.MustCompile(`.*age.* = false, `).MatchString(sql) {
t.Errorf("Failed to generate sql, got %v", sql)
}

stmt = dryRunDB.Model(&user).Where("id = ?", 1).Updates(map[string]interface{}{"age": ageFloat(0.12345678)}).Statement
sql = DB.Dialector.Explain(stmt.SQL.String(), stmt.Vars...)
if !regexp.MustCompile(`.*age.*=0.123457,`).MatchString(sql) {
if !regexp.MustCompile(`.*age.* = 0.123457, `).MatchString(sql) {
t.Errorf("Failed to generate sql, got %v", sql)
}
}
Expand Down

0 comments on commit 6508f28

Please sign in to comment.