From 025f511efce6fb5d192399942e52f3b4e710a701 Mon Sep 17 00:00:00 2001 From: tr1v3r Date: Tue, 16 Jan 2024 14:18:42 +0800 Subject: [PATCH] tests: update test data --- tests/.expect/dal_2/query/banks.gen_test.go | 4 +- .../dal_2/query/credit_cards.gen_test.go | 4 +- .../.expect/dal_2/query/customers.gen_test.go | 4 +- tests/.expect/dal_2/query/gen_test.go | 16 ++--- tests/.expect/dal_2/query/people.gen_test.go | 4 +- tests/.expect/dal_2/query/users.gen_test.go | 4 +- tests/.expect/dal_3/query/banks.gen_test.go | 4 +- .../dal_3/query/credit_cards.gen_test.go | 4 +- .../.expect/dal_3/query/customers.gen_test.go | 4 +- tests/.expect/dal_3/query/gen_test.go | 16 ++--- tests/.expect/dal_3/query/people.gen_test.go | 4 +- tests/.expect/dal_3/query/users.gen_test.go | 4 +- tests/.expect/dal_4/query/banks.gen_test.go | 4 +- .../dal_4/query/credit_cards.gen_test.go | 4 +- .../.expect/dal_4/query/customers.gen_test.go | 4 +- tests/.expect/dal_4/query/gen_test.go | 16 ++--- tests/.expect/dal_4/query/people.gen_test.go | 4 +- tests/.expect/dal_4/query/users.gen_test.go | 62 +++++++++---------- tests/.expect/dal_5/query/gen_test.go | 16 ++--- tests/.expect/dal_5/query/users.gen_test.go | 4 +- tests/.expect/dal_6/query/gen_test.go | 16 ++--- tests/.expect/dal_6/query/users.gen_test.go | 4 +- 22 files changed, 103 insertions(+), 103 deletions(-) diff --git a/tests/.expect/dal_2/query/banks.gen_test.go b/tests/.expect/dal_2/query/banks.gen_test.go index 9968b01e..1be37667 100644 --- a/tests/.expect/dal_2/query/banks.gen_test.go +++ b/tests/.expect/dal_2/query/banks.gen_test.go @@ -17,14 +17,14 @@ import ( func init() { InitializeDB() - err := db.AutoMigrate(&model.Bank{}) + err := _gen_test_db.AutoMigrate(&model.Bank{}) if err != nil { fmt.Printf("Error: AutoMigrate(&model.Bank{}) fail: %s", err) } } func Test_bankQuery(t *testing.T) { - bank := newBank(db) + bank := newBank(_gen_test_db) bank = *bank.As(bank.TableName()) _do := bank.WithContext(context.Background()).Debug() diff --git a/tests/.expect/dal_2/query/credit_cards.gen_test.go b/tests/.expect/dal_2/query/credit_cards.gen_test.go index 5f26f1df..27470433 100644 --- a/tests/.expect/dal_2/query/credit_cards.gen_test.go +++ b/tests/.expect/dal_2/query/credit_cards.gen_test.go @@ -17,14 +17,14 @@ import ( func init() { InitializeDB() - err := db.AutoMigrate(&model.CreditCard{}) + err := _gen_test_db.AutoMigrate(&model.CreditCard{}) if err != nil { fmt.Printf("Error: AutoMigrate(&model.CreditCard{}) fail: %s", err) } } func Test_creditCardQuery(t *testing.T) { - creditCard := newCreditCard(db) + creditCard := newCreditCard(_gen_test_db) creditCard = *creditCard.As(creditCard.TableName()) _do := creditCard.WithContext(context.Background()).Debug() diff --git a/tests/.expect/dal_2/query/customers.gen_test.go b/tests/.expect/dal_2/query/customers.gen_test.go index 0ff28c33..85bba4eb 100644 --- a/tests/.expect/dal_2/query/customers.gen_test.go +++ b/tests/.expect/dal_2/query/customers.gen_test.go @@ -17,14 +17,14 @@ import ( func init() { InitializeDB() - err := db.AutoMigrate(&model.Customer{}) + err := _gen_test_db.AutoMigrate(&model.Customer{}) if err != nil { fmt.Printf("Error: AutoMigrate(&model.Customer{}) fail: %s", err) } } func Test_customerQuery(t *testing.T) { - customer := newCustomer(db) + customer := newCustomer(_gen_test_db) customer = *customer.As(customer.TableName()) _do := customer.WithContext(context.Background()).Debug() diff --git a/tests/.expect/dal_2/query/gen_test.go b/tests/.expect/dal_2/query/gen_test.go index 9416fe5f..5dcc03e4 100644 --- a/tests/.expect/dal_2/query/gen_test.go +++ b/tests/.expect/dal_2/query/gen_test.go @@ -30,12 +30,12 @@ type TestCase struct { const dbName = "gen_test.db" -var db *gorm.DB -var once sync.Once +var _gen_test_db *gorm.DB +var _gen_test_once sync.Once func init() { InitializeDB() - db.AutoMigrate(&_another{}) + _gen_test_db.AutoMigrate(&_another{}) } func InitializeDB() { @@ -61,15 +61,15 @@ type _another struct { func (*_another) TableName() string { return "another_for_unit_test" } func Test_Available(t *testing.T) { - if !Use(db).Available() { + if !Use(_gen_test_db).Available() { t.Errorf("query.Available() == false") } } func Test_WithContext(t *testing.T) { - query := Use(db) + query := Use(_gen_test_db) if !query.Available() { - t.Errorf("query Use(db) fail: query.Available() == false") + t.Errorf("query Use(_gen_test_db) fail: query.Available() == false") } type Content string @@ -90,9 +90,9 @@ func Test_WithContext(t *testing.T) { } func Test_Transaction(t *testing.T) { - query := Use(db) + query := Use(_gen_test_db) if !query.Available() { - t.Errorf("query Use(db) fail: query.Available() == false") + t.Errorf("query Use(_gen_test_db) fail: query.Available() == false") } err := query.Transaction(func(tx *Query) error { return nil }) diff --git a/tests/.expect/dal_2/query/people.gen_test.go b/tests/.expect/dal_2/query/people.gen_test.go index 3ac19e9f..635b9e69 100644 --- a/tests/.expect/dal_2/query/people.gen_test.go +++ b/tests/.expect/dal_2/query/people.gen_test.go @@ -17,14 +17,14 @@ import ( func init() { InitializeDB() - err := db.AutoMigrate(&model.Person{}) + err := _gen_test_db.AutoMigrate(&model.Person{}) if err != nil { fmt.Printf("Error: AutoMigrate(&model.Person{}) fail: %s", err) } } func Test_personQuery(t *testing.T) { - person := newPerson(db) + person := newPerson(_gen_test_db) person = *person.As(person.TableName()) _do := person.WithContext(context.Background()).Debug() diff --git a/tests/.expect/dal_2/query/users.gen_test.go b/tests/.expect/dal_2/query/users.gen_test.go index 50a98d19..a9d1336d 100644 --- a/tests/.expect/dal_2/query/users.gen_test.go +++ b/tests/.expect/dal_2/query/users.gen_test.go @@ -17,14 +17,14 @@ import ( func init() { InitializeDB() - err := db.AutoMigrate(&model.User{}) + err := _gen_test_db.AutoMigrate(&model.User{}) if err != nil { fmt.Printf("Error: AutoMigrate(&model.User{}) fail: %s", err) } } func Test_userQuery(t *testing.T) { - user := newUser(db) + user := newUser(_gen_test_db) user = *user.As(user.TableName()) _do := user.WithContext(context.Background()).Debug() diff --git a/tests/.expect/dal_3/query/banks.gen_test.go b/tests/.expect/dal_3/query/banks.gen_test.go index 138e0e6f..1f79b6cb 100644 --- a/tests/.expect/dal_3/query/banks.gen_test.go +++ b/tests/.expect/dal_3/query/banks.gen_test.go @@ -17,14 +17,14 @@ import ( func init() { InitializeDB() - err := db.AutoMigrate(&model.Bank{}) + err := _gen_test_db.AutoMigrate(&model.Bank{}) if err != nil { fmt.Printf("Error: AutoMigrate(&model.Bank{}) fail: %s", err) } } func Test_bankQuery(t *testing.T) { - bank := newBank(db) + bank := newBank(_gen_test_db) bank = *bank.As(bank.TableName()) _do := bank.WithContext(context.Background()).Debug() diff --git a/tests/.expect/dal_3/query/credit_cards.gen_test.go b/tests/.expect/dal_3/query/credit_cards.gen_test.go index b643a873..837da168 100644 --- a/tests/.expect/dal_3/query/credit_cards.gen_test.go +++ b/tests/.expect/dal_3/query/credit_cards.gen_test.go @@ -17,14 +17,14 @@ import ( func init() { InitializeDB() - err := db.AutoMigrate(&model.CreditCard{}) + err := _gen_test_db.AutoMigrate(&model.CreditCard{}) if err != nil { fmt.Printf("Error: AutoMigrate(&model.CreditCard{}) fail: %s", err) } } func Test_creditCardQuery(t *testing.T) { - creditCard := newCreditCard(db) + creditCard := newCreditCard(_gen_test_db) creditCard = *creditCard.As(creditCard.TableName()) _do := creditCard.WithContext(context.Background()).Debug() diff --git a/tests/.expect/dal_3/query/customers.gen_test.go b/tests/.expect/dal_3/query/customers.gen_test.go index 537bb440..dcd0b251 100644 --- a/tests/.expect/dal_3/query/customers.gen_test.go +++ b/tests/.expect/dal_3/query/customers.gen_test.go @@ -17,14 +17,14 @@ import ( func init() { InitializeDB() - err := db.AutoMigrate(&model.Customer{}) + err := _gen_test_db.AutoMigrate(&model.Customer{}) if err != nil { fmt.Printf("Error: AutoMigrate(&model.Customer{}) fail: %s", err) } } func Test_customerQuery(t *testing.T) { - customer := newCustomer(db) + customer := newCustomer(_gen_test_db) customer = *customer.As(customer.TableName()) _do := customer.WithContext(context.Background()).Debug() diff --git a/tests/.expect/dal_3/query/gen_test.go b/tests/.expect/dal_3/query/gen_test.go index 9416fe5f..5dcc03e4 100644 --- a/tests/.expect/dal_3/query/gen_test.go +++ b/tests/.expect/dal_3/query/gen_test.go @@ -30,12 +30,12 @@ type TestCase struct { const dbName = "gen_test.db" -var db *gorm.DB -var once sync.Once +var _gen_test_db *gorm.DB +var _gen_test_once sync.Once func init() { InitializeDB() - db.AutoMigrate(&_another{}) + _gen_test_db.AutoMigrate(&_another{}) } func InitializeDB() { @@ -61,15 +61,15 @@ type _another struct { func (*_another) TableName() string { return "another_for_unit_test" } func Test_Available(t *testing.T) { - if !Use(db).Available() { + if !Use(_gen_test_db).Available() { t.Errorf("query.Available() == false") } } func Test_WithContext(t *testing.T) { - query := Use(db) + query := Use(_gen_test_db) if !query.Available() { - t.Errorf("query Use(db) fail: query.Available() == false") + t.Errorf("query Use(_gen_test_db) fail: query.Available() == false") } type Content string @@ -90,9 +90,9 @@ func Test_WithContext(t *testing.T) { } func Test_Transaction(t *testing.T) { - query := Use(db) + query := Use(_gen_test_db) if !query.Available() { - t.Errorf("query Use(db) fail: query.Available() == false") + t.Errorf("query Use(_gen_test_db) fail: query.Available() == false") } err := query.Transaction(func(tx *Query) error { return nil }) diff --git a/tests/.expect/dal_3/query/people.gen_test.go b/tests/.expect/dal_3/query/people.gen_test.go index 20a6823d..4aede1ef 100644 --- a/tests/.expect/dal_3/query/people.gen_test.go +++ b/tests/.expect/dal_3/query/people.gen_test.go @@ -17,14 +17,14 @@ import ( func init() { InitializeDB() - err := db.AutoMigrate(&model.Person{}) + err := _gen_test_db.AutoMigrate(&model.Person{}) if err != nil { fmt.Printf("Error: AutoMigrate(&model.Person{}) fail: %s", err) } } func Test_personQuery(t *testing.T) { - person := newPerson(db) + person := newPerson(_gen_test_db) person = *person.As(person.TableName()) _do := person.WithContext(context.Background()).Debug() diff --git a/tests/.expect/dal_3/query/users.gen_test.go b/tests/.expect/dal_3/query/users.gen_test.go index e1868b4a..482fd5e0 100644 --- a/tests/.expect/dal_3/query/users.gen_test.go +++ b/tests/.expect/dal_3/query/users.gen_test.go @@ -17,14 +17,14 @@ import ( func init() { InitializeDB() - err := db.AutoMigrate(&model.User{}) + err := _gen_test_db.AutoMigrate(&model.User{}) if err != nil { fmt.Printf("Error: AutoMigrate(&model.User{}) fail: %s", err) } } func Test_userQuery(t *testing.T) { - user := newUser(db) + user := newUser(_gen_test_db) user = *user.As(user.TableName()) _do := user.WithContext(context.Background()).Debug() diff --git a/tests/.expect/dal_4/query/banks.gen_test.go b/tests/.expect/dal_4/query/banks.gen_test.go index a7c0dc74..2726fd6a 100644 --- a/tests/.expect/dal_4/query/banks.gen_test.go +++ b/tests/.expect/dal_4/query/banks.gen_test.go @@ -17,14 +17,14 @@ import ( func init() { InitializeDB() - err := db.AutoMigrate(&model.Bank{}) + err := _gen_test_db.AutoMigrate(&model.Bank{}) if err != nil { fmt.Printf("Error: AutoMigrate(&model.Bank{}) fail: %s", err) } } func Test_bankQuery(t *testing.T) { - bank := newBank(db) + bank := newBank(_gen_test_db) bank = *bank.As(bank.TableName()) _do := bank.WithContext(context.Background()).Debug() diff --git a/tests/.expect/dal_4/query/credit_cards.gen_test.go b/tests/.expect/dal_4/query/credit_cards.gen_test.go index ee035cd6..5c193547 100644 --- a/tests/.expect/dal_4/query/credit_cards.gen_test.go +++ b/tests/.expect/dal_4/query/credit_cards.gen_test.go @@ -17,14 +17,14 @@ import ( func init() { InitializeDB() - err := db.AutoMigrate(&model.CreditCard{}) + err := _gen_test_db.AutoMigrate(&model.CreditCard{}) if err != nil { fmt.Printf("Error: AutoMigrate(&model.CreditCard{}) fail: %s", err) } } func Test_creditCardQuery(t *testing.T) { - creditCard := newCreditCard(db) + creditCard := newCreditCard(_gen_test_db) creditCard = *creditCard.As(creditCard.TableName()) _do := creditCard.WithContext(context.Background()).Debug() diff --git a/tests/.expect/dal_4/query/customers.gen_test.go b/tests/.expect/dal_4/query/customers.gen_test.go index d6865c79..a9990754 100644 --- a/tests/.expect/dal_4/query/customers.gen_test.go +++ b/tests/.expect/dal_4/query/customers.gen_test.go @@ -17,14 +17,14 @@ import ( func init() { InitializeDB() - err := db.AutoMigrate(&model.Customer{}) + err := _gen_test_db.AutoMigrate(&model.Customer{}) if err != nil { fmt.Printf("Error: AutoMigrate(&model.Customer{}) fail: %s", err) } } func Test_customerQuery(t *testing.T) { - customer := newCustomer(db) + customer := newCustomer(_gen_test_db) customer = *customer.As(customer.TableName()) _do := customer.WithContext(context.Background()).Debug() diff --git a/tests/.expect/dal_4/query/gen_test.go b/tests/.expect/dal_4/query/gen_test.go index 9416fe5f..5dcc03e4 100644 --- a/tests/.expect/dal_4/query/gen_test.go +++ b/tests/.expect/dal_4/query/gen_test.go @@ -30,12 +30,12 @@ type TestCase struct { const dbName = "gen_test.db" -var db *gorm.DB -var once sync.Once +var _gen_test_db *gorm.DB +var _gen_test_once sync.Once func init() { InitializeDB() - db.AutoMigrate(&_another{}) + _gen_test_db.AutoMigrate(&_another{}) } func InitializeDB() { @@ -61,15 +61,15 @@ type _another struct { func (*_another) TableName() string { return "another_for_unit_test" } func Test_Available(t *testing.T) { - if !Use(db).Available() { + if !Use(_gen_test_db).Available() { t.Errorf("query.Available() == false") } } func Test_WithContext(t *testing.T) { - query := Use(db) + query := Use(_gen_test_db) if !query.Available() { - t.Errorf("query Use(db) fail: query.Available() == false") + t.Errorf("query Use(_gen_test_db) fail: query.Available() == false") } type Content string @@ -90,9 +90,9 @@ func Test_WithContext(t *testing.T) { } func Test_Transaction(t *testing.T) { - query := Use(db) + query := Use(_gen_test_db) if !query.Available() { - t.Errorf("query Use(db) fail: query.Available() == false") + t.Errorf("query Use(_gen_test_db) fail: query.Available() == false") } err := query.Transaction(func(tx *Query) error { return nil }) diff --git a/tests/.expect/dal_4/query/people.gen_test.go b/tests/.expect/dal_4/query/people.gen_test.go index d0da115b..fcf573a7 100644 --- a/tests/.expect/dal_4/query/people.gen_test.go +++ b/tests/.expect/dal_4/query/people.gen_test.go @@ -17,14 +17,14 @@ import ( func init() { InitializeDB() - err := db.AutoMigrate(&model.Person{}) + err := _gen_test_db.AutoMigrate(&model.Person{}) if err != nil { fmt.Printf("Error: AutoMigrate(&model.Person{}) fail: %s", err) } } func Test_personQuery(t *testing.T) { - person := newPerson(db) + person := newPerson(_gen_test_db) person = *person.As(person.TableName()) _do := person.WithContext(context.Background()).Debug() diff --git a/tests/.expect/dal_4/query/users.gen_test.go b/tests/.expect/dal_4/query/users.gen_test.go index 8ac43965..2c9a7c44 100644 --- a/tests/.expect/dal_4/query/users.gen_test.go +++ b/tests/.expect/dal_4/query/users.gen_test.go @@ -19,14 +19,14 @@ import ( func init() { InitializeDB() - err := db.AutoMigrate(&model.User{}) + err := _gen_test_db.AutoMigrate(&model.User{}) if err != nil { fmt.Printf("Error: AutoMigrate(&model.User{}) fail: %s", err) } } func Test_userQuery(t *testing.T) { - user := newUser(db) + user := newUser(_gen_test_db) user = *user.As(user.TableName()) _do := user.WithContext(context.Background()).Debug() @@ -149,7 +149,7 @@ func Test_userQuery(t *testing.T) { var UserFindByUsersTestCase = []TestCase{} func Test_user_FindByUsers(t *testing.T) { - user := newUser(db) + user := newUser(_gen_test_db) do := user.WithContext(context.Background()).Debug() for i, tt := range UserFindByUsersTestCase { @@ -163,7 +163,7 @@ func Test_user_FindByUsers(t *testing.T) { var UserFindByComplexIfTestCase = []TestCase{} func Test_user_FindByComplexIf(t *testing.T) { - user := newUser(db) + user := newUser(_gen_test_db) do := user.WithContext(context.Background()).Debug() for i, tt := range UserFindByComplexIfTestCase { @@ -177,7 +177,7 @@ func Test_user_FindByComplexIf(t *testing.T) { var UserFindByIfTimeTestCase = []TestCase{} func Test_user_FindByIfTime(t *testing.T) { - user := newUser(db) + user := newUser(_gen_test_db) do := user.WithContext(context.Background()).Debug() for i, tt := range UserFindByIfTimeTestCase { @@ -191,7 +191,7 @@ func Test_user_FindByIfTime(t *testing.T) { var UserTestForTestCase = []TestCase{} func Test_user_TestFor(t *testing.T) { - user := newUser(db) + user := newUser(_gen_test_db) do := user.WithContext(context.Background()).Debug() for i, tt := range UserTestForTestCase { @@ -206,7 +206,7 @@ func Test_user_TestFor(t *testing.T) { var UserTestForKeyTestCase = []TestCase{} func Test_user_TestForKey(t *testing.T) { - user := newUser(db) + user := newUser(_gen_test_db) do := user.WithContext(context.Background()).Debug() for i, tt := range UserTestForKeyTestCase { @@ -221,7 +221,7 @@ func Test_user_TestForKey(t *testing.T) { var UserTestForOrTestCase = []TestCase{} func Test_user_TestForOr(t *testing.T) { - user := newUser(db) + user := newUser(_gen_test_db) do := user.WithContext(context.Background()).Debug() for i, tt := range UserTestForOrTestCase { @@ -236,7 +236,7 @@ func Test_user_TestForOr(t *testing.T) { var UserTestIfInForTestCase = []TestCase{} func Test_user_TestIfInFor(t *testing.T) { - user := newUser(db) + user := newUser(_gen_test_db) do := user.WithContext(context.Background()).Debug() for i, tt := range UserTestIfInForTestCase { @@ -251,7 +251,7 @@ func Test_user_TestIfInFor(t *testing.T) { var UserTestForInIfTestCase = []TestCase{} func Test_user_TestForInIf(t *testing.T) { - user := newUser(db) + user := newUser(_gen_test_db) do := user.WithContext(context.Background()).Debug() for i, tt := range UserTestForInIfTestCase { @@ -266,7 +266,7 @@ func Test_user_TestForInIf(t *testing.T) { var UserTestForInWhereTestCase = []TestCase{} func Test_user_TestForInWhere(t *testing.T) { - user := newUser(db) + user := newUser(_gen_test_db) do := user.WithContext(context.Background()).Debug() for i, tt := range UserTestForInWhereTestCase { @@ -281,7 +281,7 @@ func Test_user_TestForInWhere(t *testing.T) { var UserTestForUserListTestCase = []TestCase{} func Test_user_TestForUserList(t *testing.T) { - user := newUser(db) + user := newUser(_gen_test_db) do := user.WithContext(context.Background()).Debug() for i, tt := range UserTestForUserListTestCase { @@ -296,7 +296,7 @@ func Test_user_TestForUserList(t *testing.T) { var UserTestForMapTestCase = []TestCase{} func Test_user_TestForMap(t *testing.T) { - user := newUser(db) + user := newUser(_gen_test_db) do := user.WithContext(context.Background()).Debug() for i, tt := range UserTestForMapTestCase { @@ -311,7 +311,7 @@ func Test_user_TestForMap(t *testing.T) { var UserTestIfInIfTestCase = []TestCase{} func Test_user_TestIfInIf(t *testing.T) { - user := newUser(db) + user := newUser(_gen_test_db) do := user.WithContext(context.Background()).Debug() for i, tt := range UserTestIfInIfTestCase { @@ -325,7 +325,7 @@ func Test_user_TestIfInIf(t *testing.T) { var UserTestMoreForTestCase = []TestCase{} func Test_user_TestMoreFor(t *testing.T) { - user := newUser(db) + user := newUser(_gen_test_db) do := user.WithContext(context.Background()).Debug() for i, tt := range UserTestMoreForTestCase { @@ -339,7 +339,7 @@ func Test_user_TestMoreFor(t *testing.T) { var UserTestMoreFor2TestCase = []TestCase{} func Test_user_TestMoreFor2(t *testing.T) { - user := newUser(db) + user := newUser(_gen_test_db) do := user.WithContext(context.Background()).Debug() for i, tt := range UserTestMoreFor2TestCase { @@ -353,7 +353,7 @@ func Test_user_TestMoreFor2(t *testing.T) { var UserTestForInSetTestCase = []TestCase{} func Test_user_TestForInSet(t *testing.T) { - user := newUser(db) + user := newUser(_gen_test_db) do := user.WithContext(context.Background()).Debug() for i, tt := range UserTestForInSetTestCase { @@ -367,7 +367,7 @@ func Test_user_TestForInSet(t *testing.T) { var UserTestInsertMoreInfoTestCase = []TestCase{} func Test_user_TestInsertMoreInfo(t *testing.T) { - user := newUser(db) + user := newUser(_gen_test_db) do := user.WithContext(context.Background()).Debug() for i, tt := range UserTestInsertMoreInfoTestCase { @@ -381,7 +381,7 @@ func Test_user_TestInsertMoreInfo(t *testing.T) { var UserTestIfElseForTestCase = []TestCase{} func Test_user_TestIfElseFor(t *testing.T) { - user := newUser(db) + user := newUser(_gen_test_db) do := user.WithContext(context.Background()).Debug() for i, tt := range UserTestIfElseForTestCase { @@ -395,7 +395,7 @@ func Test_user_TestIfElseFor(t *testing.T) { var UserTestForLikeTestCase = []TestCase{} func Test_user_TestForLike(t *testing.T) { - user := newUser(db) + user := newUser(_gen_test_db) do := user.WithContext(context.Background()).Debug() for i, tt := range UserTestForLikeTestCase { @@ -409,7 +409,7 @@ func Test_user_TestForLike(t *testing.T) { var UserAddUserTestCase = []TestCase{} func Test_user_AddUser(t *testing.T) { - user := newUser(db) + user := newUser(_gen_test_db) do := user.WithContext(context.Background()).Debug() for i, tt := range UserAddUserTestCase { @@ -424,7 +424,7 @@ func Test_user_AddUser(t *testing.T) { var UserAddUser1TestCase = []TestCase{} func Test_user_AddUser1(t *testing.T) { - user := newUser(db) + user := newUser(_gen_test_db) do := user.WithContext(context.Background()).Debug() for i, tt := range UserAddUser1TestCase { @@ -439,7 +439,7 @@ func Test_user_AddUser1(t *testing.T) { var UserAddUser2TestCase = []TestCase{} func Test_user_AddUser2(t *testing.T) { - user := newUser(db) + user := newUser(_gen_test_db) do := user.WithContext(context.Background()).Debug() for i, tt := range UserAddUser2TestCase { @@ -453,7 +453,7 @@ func Test_user_AddUser2(t *testing.T) { var UserAddUser3TestCase = []TestCase{} func Test_user_AddUser3(t *testing.T) { - user := newUser(db) + user := newUser(_gen_test_db) do := user.WithContext(context.Background()).Debug() for i, tt := range UserAddUser3TestCase { @@ -467,7 +467,7 @@ func Test_user_AddUser3(t *testing.T) { var UserAddUser4TestCase = []TestCase{} func Test_user_AddUser4(t *testing.T) { - user := newUser(db) + user := newUser(_gen_test_db) do := user.WithContext(context.Background()).Debug() for i, tt := range UserAddUser4TestCase { @@ -481,7 +481,7 @@ func Test_user_AddUser4(t *testing.T) { var UserAddUser5TestCase = []TestCase{} func Test_user_AddUser5(t *testing.T) { - user := newUser(db) + user := newUser(_gen_test_db) do := user.WithContext(context.Background()).Debug() for i, tt := range UserAddUser5TestCase { @@ -495,7 +495,7 @@ func Test_user_AddUser5(t *testing.T) { var UserAddUser6TestCase = []TestCase{} func Test_user_AddUser6(t *testing.T) { - user := newUser(db) + user := newUser(_gen_test_db) do := user.WithContext(context.Background()).Debug() for i, tt := range UserAddUser6TestCase { @@ -510,7 +510,7 @@ func Test_user_AddUser6(t *testing.T) { var UserFindByIDTestCase = []TestCase{} func Test_user_FindByID(t *testing.T) { - user := newUser(db) + user := newUser(_gen_test_db) do := user.WithContext(context.Background()).Debug() for i, tt := range UserFindByIDTestCase { @@ -524,7 +524,7 @@ func Test_user_FindByID(t *testing.T) { var UserLikeSearchTestCase = []TestCase{} func Test_user_LikeSearch(t *testing.T) { - user := newUser(db) + user := newUser(_gen_test_db) do := user.WithContext(context.Background()).Debug() for i, tt := range UserLikeSearchTestCase { @@ -538,7 +538,7 @@ func Test_user_LikeSearch(t *testing.T) { var UserInSearchTestCase = []TestCase{} func Test_user_InSearch(t *testing.T) { - user := newUser(db) + user := newUser(_gen_test_db) do := user.WithContext(context.Background()).Debug() for i, tt := range UserInSearchTestCase { @@ -552,7 +552,7 @@ func Test_user_InSearch(t *testing.T) { var UserColumnSearchTestCase = []TestCase{} func Test_user_ColumnSearch(t *testing.T) { - user := newUser(db) + user := newUser(_gen_test_db) do := user.WithContext(context.Background()).Debug() for i, tt := range UserColumnSearchTestCase { diff --git a/tests/.expect/dal_5/query/gen_test.go b/tests/.expect/dal_5/query/gen_test.go index 40cdc69b..bc707213 100644 --- a/tests/.expect/dal_5/query/gen_test.go +++ b/tests/.expect/dal_5/query/gen_test.go @@ -30,12 +30,12 @@ type TestCase struct { const dbName = "gen_test.db" -var db *gorm.DB -var once sync.Once +var _gen_test_db *gorm.DB +var _gen_test_once sync.Once func init() { InitializeDB() - db.AutoMigrate(&_another{}) + _gen_test_db.AutoMigrate(&_another{}) } func InitializeDB() { @@ -61,15 +61,15 @@ type _another struct { func (*_another) TableName() string { return "another_for_unit_test" } func Test_Available(t *testing.T) { - if !Use(db).Available() { + if !Use(_gen_test_db).Available() { t.Errorf("query.Available() == false") } } func Test_WithContext(t *testing.T) { - query := Use(db) + query := Use(_gen_test_db) if !query.Available() { - t.Errorf("query Use(db) fail: query.Available() == false") + t.Errorf("query Use(_gen_test_db) fail: query.Available() == false") } type Content string @@ -86,9 +86,9 @@ func Test_WithContext(t *testing.T) { } func Test_Transaction(t *testing.T) { - query := Use(db) + query := Use(_gen_test_db) if !query.Available() { - t.Errorf("query Use(db) fail: query.Available() == false") + t.Errorf("query Use(_gen_test_db) fail: query.Available() == false") } err := query.Transaction(func(tx *Query) error { return nil }) diff --git a/tests/.expect/dal_5/query/users.gen_test.go b/tests/.expect/dal_5/query/users.gen_test.go index e8535867..15a1edaf 100644 --- a/tests/.expect/dal_5/query/users.gen_test.go +++ b/tests/.expect/dal_5/query/users.gen_test.go @@ -17,14 +17,14 @@ import ( func init() { InitializeDB() - err := db.AutoMigrate(&model.User{}) + err := _gen_test_db.AutoMigrate(&model.User{}) if err != nil { fmt.Printf("Error: AutoMigrate(&model.User{}) fail: %s", err) } } func Test_userQuery(t *testing.T) { - user := newUser(db) + user := newUser(_gen_test_db) user = *user.As(user.TableName()) _do := user.WithContext(context.Background()).Debug() diff --git a/tests/.expect/dal_6/query/gen_test.go b/tests/.expect/dal_6/query/gen_test.go index 40cdc69b..bc707213 100644 --- a/tests/.expect/dal_6/query/gen_test.go +++ b/tests/.expect/dal_6/query/gen_test.go @@ -30,12 +30,12 @@ type TestCase struct { const dbName = "gen_test.db" -var db *gorm.DB -var once sync.Once +var _gen_test_db *gorm.DB +var _gen_test_once sync.Once func init() { InitializeDB() - db.AutoMigrate(&_another{}) + _gen_test_db.AutoMigrate(&_another{}) } func InitializeDB() { @@ -61,15 +61,15 @@ type _another struct { func (*_another) TableName() string { return "another_for_unit_test" } func Test_Available(t *testing.T) { - if !Use(db).Available() { + if !Use(_gen_test_db).Available() { t.Errorf("query.Available() == false") } } func Test_WithContext(t *testing.T) { - query := Use(db) + query := Use(_gen_test_db) if !query.Available() { - t.Errorf("query Use(db) fail: query.Available() == false") + t.Errorf("query Use(_gen_test_db) fail: query.Available() == false") } type Content string @@ -86,9 +86,9 @@ func Test_WithContext(t *testing.T) { } func Test_Transaction(t *testing.T) { - query := Use(db) + query := Use(_gen_test_db) if !query.Available() { - t.Errorf("query Use(db) fail: query.Available() == false") + t.Errorf("query Use(_gen_test_db) fail: query.Available() == false") } err := query.Transaction(func(tx *Query) error { return nil }) diff --git a/tests/.expect/dal_6/query/users.gen_test.go b/tests/.expect/dal_6/query/users.gen_test.go index fdf49efa..84c890bf 100644 --- a/tests/.expect/dal_6/query/users.gen_test.go +++ b/tests/.expect/dal_6/query/users.gen_test.go @@ -17,14 +17,14 @@ import ( func init() { InitializeDB() - err := db.AutoMigrate(&model.User{}) + err := _gen_test_db.AutoMigrate(&model.User{}) if err != nil { fmt.Printf("Error: AutoMigrate(&model.User{}) fail: %s", err) } } func Test_userQuery(t *testing.T) { - user := newUser(db) + user := newUser(_gen_test_db) user = *user.As(user.TableName()) _do := user.WithContext(context.Background()).Debug()