Example #1
0
func createTestAccount(settings configuration.SettingsProvider) {
	log.Info("Creating test account for test")
	dbProvider := NewSingletonDbProvider(settings)
	uowFactory := NewSqlUnitOfWorkFactory(dbProvider)
	uow, _ := uowFactory.CreateUnitOfWork(nil)
	accountRepository := uow.GetAccountRepository()

	existingAccount, _ := accountRepository.GetAccountByUserId("*****@*****.**")

	if existingAccount == nil {
		pw, _ := bcrypt.GenerateFromPassword([]byte("Ab12345!"), 14)
		newAccount := new(entities.Account)
		newAccount.UserId = "*****@*****.**"
		newAccount.Roles = []string{"user, admin"}
		newAccount.Password = pw
		accountRepository.CreateAccount(newAccount)
	}

	_ = uow.Commit()
}