From 3963bb37a49b14e052747007011c264961fd26bd Mon Sep 17 00:00:00 2001 From: Sonja Happ Date: Wed, 4 Sep 2019 09:07:09 +0200 Subject: [PATCH] use copies of global test data when adding users to DB, add a function that adds admin and 2 normal users to DB --- common/database.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/common/database.go b/common/database.go index 3dba07d..8cc7662 100644 --- a/common/database.go +++ b/common/database.go @@ -94,7 +94,25 @@ func DummyInitDB() *gorm.DB { func DummyAddOnlyUserTableWithAdminDB(db *gorm.DB) { db.AutoMigrate(&User{}) - checkErr(db.Create(&User0).Error) + + //create a copy of global test data + user0 := User0 + // add admin user to DB + checkErr(db.Create(&user0).Error) +} + +func DummyAddOnlyUserTableWithAdminAndUsersDB(db *gorm.DB) { + db.AutoMigrate(&User{}) + + //create a copy of global test data + user0 := User0 + userA := UserA + userB := UserB + // add admin user to DB + checkErr(db.Create(&user0).Error) + // add normal users to DB + checkErr(db.Create(&userA).Error) + checkErr(db.Create(&userB).Error) } // Migrates models and populates them with data