From 9fcc546a69d014a81a5c459879f2a1ce80c4c97f Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Wed, 26 Feb 2020 19:06:42 +0800 Subject: [PATCH] Fix tests --- clause/benchmarks_test.go | 4 ++-- clause/clause_test.go | 2 +- clause/expression_test.go | 2 +- logger/sql_test.go | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/clause/benchmarks_test.go b/clause/benchmarks_test.go index 3813fd8e..33d3430a 100644 --- a/clause/benchmarks_test.go +++ b/clause/benchmarks_test.go @@ -11,7 +11,7 @@ import ( ) func BenchmarkSelect(b *testing.B) { - user, _, _ := schema.Parse(&tests.User{}, &sync.Map{}, db.NamingStrategy) + user, _ := schema.Parse(&tests.User{}, &sync.Map{}, db.NamingStrategy) for i := 0; i < b.N; i++ { stmt := gorm.Statement{DB: db, Table: user.Table, Schema: user, Clauses: map[string]clause.Clause{}} @@ -27,7 +27,7 @@ func BenchmarkSelect(b *testing.B) { } func BenchmarkComplexSelect(b *testing.B) { - user, _, _ := schema.Parse(&tests.User{}, &sync.Map{}, db.NamingStrategy) + user, _ := schema.Parse(&tests.User{}, &sync.Map{}, db.NamingStrategy) for i := 0; i < b.N; i++ { stmt := gorm.Statement{DB: db, Table: user.Table, Schema: user, Clauses: map[string]clause.Clause{}} diff --git a/clause/clause_test.go b/clause/clause_test.go index 8e458043..30ea9343 100644 --- a/clause/clause_test.go +++ b/clause/clause_test.go @@ -18,7 +18,7 @@ func checkBuildClauses(t *testing.T, clauses []clause.Interface, result string, var ( buildNames []string buildNamesMap = map[string]bool{} - user, _, _ = schema.Parse(&tests.User{}, &sync.Map{}, db.NamingStrategy) + user, _ = schema.Parse(&tests.User{}, &sync.Map{}, db.NamingStrategy) stmt = gorm.Statement{DB: db, Table: user.Table, Schema: user, Clauses: map[string]clause.Clause{}} ) diff --git a/clause/expression_test.go b/clause/expression_test.go index 363b4047..e51d189e 100644 --- a/clause/expression_test.go +++ b/clause/expression_test.go @@ -24,7 +24,7 @@ func TestExpr(t *testing.T) { for idx, result := range results { t.Run(fmt.Sprintf("case #%v", idx), func(t *testing.T) { - user, _, _ := schema.Parse(&tests.User{}, &sync.Map{}, db.NamingStrategy) + user, _ := schema.Parse(&tests.User{}, &sync.Map{}, db.NamingStrategy) stmt := &gorm.Statement{DB: db, Table: user.Table, Schema: user, Clauses: map[string]clause.Clause{}} clause.Expr{SQL: result.SQL, Vars: result.Vars}.Build(stmt) if stmt.SQL.String() != result.Result { diff --git a/logger/sql_test.go b/logger/sql_test.go index aee064d8..dd7b80c8 100644 --- a/logger/sql_test.go +++ b/logger/sql_test.go @@ -30,19 +30,19 @@ func TestExplainSQL(t *testing.T) { Result: `create table users (name, age, height, actived, bytes, create_at, update_at, deleted_at, email, role, pass) values ("jinzhu", 1, 999.990000, true, "12345", "2020-02-23 11:10:10", "2020-02-23 11:10:10", NULL, "w@g.\"com", "admin", "pass")`, }, { - SQL: "create table users (name, age, height, actived, bytes, create_at, update_at, deleted_at, email, role, pass) values (@p0, @p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8, @p9, @p10)", + SQL: "create table users (name, age, height, actived, bytes, create_at, update_at, deleted_at, email, role, pass) values (@p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8, @p9, @p10, @p11)", NumericRegexp: regexp.MustCompile("@p(\\d+)"), Vars: []interface{}{"jinzhu", 1, 999.99, true, []byte("12345"), tt, &tt, nil, "w@g.com", myrole, pwd}, Result: `create table users (name, age, height, actived, bytes, create_at, update_at, deleted_at, email, role, pass) values ("jinzhu", 1, 999.990000, true, "12345", "2020-02-23 11:10:10", "2020-02-23 11:10:10", NULL, "w@g.com", "admin", "pass")`, }, { - SQL: "create table users (name, age, height, actived, bytes, create_at, update_at, deleted_at, email, role, pass) values ($2, $3, $0, $1, $6, $7, $4, $5, $8, $9, $10)", + SQL: "create table users (name, age, height, actived, bytes, create_at, update_at, deleted_at, email, role, pass) values ($3, $4, $1, $2, $7, $8, $5, $6, $9, $10, $11)", NumericRegexp: regexp.MustCompile("\\$(\\d+)"), Vars: []interface{}{999.99, true, "jinzhu", 1, &tt, nil, []byte("12345"), tt, "w@g.com", myrole, pwd}, Result: `create table users (name, age, height, actived, bytes, create_at, update_at, deleted_at, email, role, pass) values ("jinzhu", 1, 999.990000, true, "12345", "2020-02-23 11:10:10", "2020-02-23 11:10:10", NULL, "w@g.com", "admin", "pass")`, }, { - SQL: "create table users (name, age, height, actived, bytes, create_at, update_at, deleted_at, email, role, pass) values (@p0, @p10, @p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8, @p9)", + SQL: "create table users (name, age, height, actived, bytes, create_at, update_at, deleted_at, email, role, pass) values (@p1, @p11, @p2, @p3, @p4, @p5, @p6, @p7, @p8, @p9, @p10)", NumericRegexp: regexp.MustCompile("@p(\\d+)"), Vars: []interface{}{"jinzhu", 999.99, true, []byte("12345"), tt, &tt, nil, "w@g.com", myrole, pwd, 1}, Result: `create table users (name, age, height, actived, bytes, create_at, update_at, deleted_at, email, role, pass) values ("jinzhu", 1, 999.990000, true, "12345", "2020-02-23 11:10:10", "2020-02-23 11:10:10", NULL, "w@g.com", "admin", "pass")`,