()
| 174 | } |
| 175 | |
| 176 | func (s *UserTestSuite) TestCreateUserDBCreateErr() { |
| 177 | s.Fixtures.SQLMock.ExpectBegin() |
| 178 | s.Fixtures.SQLMock. |
| 179 | ExpectQuery(regexp.QuoteMeta("SELECT * FROM `users` WHERE username = ? AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT ?")). |
| 180 | WithArgs(s.Fixtures.NewUserParams.Username, 1). |
| 181 | WillReturnRows(sqlmock.NewRows([]string{"id"})) |
| 182 | s.Fixtures.SQLMock. |
| 183 | ExpectQuery(regexp.QuoteMeta("SELECT * FROM `users` WHERE email = ? AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT ?")). |
| 184 | WithArgs(s.Fixtures.NewUserParams.Email, 1). |
| 185 | WillReturnRows(sqlmock.NewRows([]string{"id"})) |
| 186 | s.Fixtures.SQLMock. |
| 187 | ExpectExec("INSERT INTO `users`"). |
| 188 | WillReturnError(fmt.Errorf("creating user mock error")) |
| 189 | s.Fixtures.SQLMock.ExpectRollback() |
| 190 | |
| 191 | _, err := s.StoreSQLMocked.CreateUser(context.Background(), s.Fixtures.NewUserParams) |
| 192 | |
| 193 | s.Require().NotNil(err) |
| 194 | s.Require().Equal("error creating user: error creating user: creating user mock error", err.Error()) |
| 195 | s.assertSQLMockExpectations() |
| 196 | } |
| 197 | |
| 198 | func (s *UserTestSuite) TestHasAdminUserNoAdmin() { |
| 199 | hasAdmin := s.Store.HasAdminUser(context.Background()) |
nothing calls this directly
no test coverage detected