diff --git a/routes/user/user_test.go b/routes/user/user_test.go index 73b22df..f5b20bb 100644 --- a/routes/user/user_test.go +++ b/routes/user/user_test.go @@ -20,8 +20,6 @@ func TestMain(m *testing.M) { db = common.DummyInitDB() defer db.Close() - common.DummyAddOnlyUserTableWithAdminDB(db) - router = gin.Default() api := router.Group("/api") @@ -34,6 +32,10 @@ func TestMain(m *testing.M) { func TestAddGetUser(t *testing.T) { + common.DropTables(db) + common.MigrateModels(db) + common.DummyAddOnlyUserTableWithAdminDB(db) + // authenticate as admin token, err := common.NewAuthenticateForTest(router, "/api/authenticate", "POST", common.AdminCredentials) @@ -78,6 +80,10 @@ func TestAddGetUser(t *testing.T) { func TestUsersNotAllowedActions(t *testing.T) { + common.DropTables(db) + common.MigrateModels(db) + common.DummyAddOnlyUserTableWithAdminDB(db) + // authenticate as admin token, err := common.NewAuthenticateForTest(router, "/api/authenticate", "POST", common.AdminCredentials) @@ -134,6 +140,10 @@ func TestUsersNotAllowedActions(t *testing.T) { func TestGetAllUsers(t *testing.T) { + common.DropTables(db) + common.MigrateModels(db) + common.DummyAddOnlyUserTableWithAdminDB(db) + // authenticate as admin token, err := common.NewAuthenticateForTest(router, "/api/authenticate", "POST", common.AdminCredentials) @@ -166,6 +176,10 @@ func TestGetAllUsers(t *testing.T) { func TestModifyAddedUserAsUser(t *testing.T) { + common.DropTables(db) + common.MigrateModels(db) + common.DummyAddOnlyUserTableWithAdminDB(db) + // authenticate as admin token, err := common.NewAuthenticateForTest(router, "/api/authenticate", "POST", common.AdminCredentials) @@ -273,6 +287,10 @@ func TestModifyAddedUserAsUser(t *testing.T) { func TestInvalidUserUpdate(t *testing.T) { + common.DropTables(db) + common.MigrateModels(db) + common.DummyAddOnlyUserTableWithAdminDB(db) + // authenticate as admin token, err := common.NewAuthenticateForTest(router, "/api/authenticate", "POST", common.AdminCredentials) @@ -320,6 +338,10 @@ func TestInvalidUserUpdate(t *testing.T) { func TestModifyAddedUserAsAdmin(t *testing.T) { + common.DropTables(db) + common.MigrateModels(db) + common.DummyAddOnlyUserTableWithAdminDB(db) + // authenticate as admin token, err := common.NewAuthenticateForTest(router, "/api/authenticate", "POST", common.AdminCredentials) @@ -398,6 +420,10 @@ func TestModifyAddedUserAsAdmin(t *testing.T) { func TestDeleteUser(t *testing.T) { + common.DropTables(db) + common.MigrateModels(db) + common.DummyAddOnlyUserTableWithAdminDB(db) + // authenticate as admin token, err := common.NewAuthenticateForTest(router, "/api/authenticate", "POST", common.AdminCredentials)