Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Randomize testing user emails and passwords #2255

Merged

Conversation

williamjallen
Copy link
Collaborator

The tests currently create users with a fixed email address and password, which can cause conflicts if multiple tests are running at the same time. See this failed test, for example. This PR resolves the issue by creating users with email addresses and passwords containing UUIDs.

Output from a test with conflicts for reference
PHPUnit 9.6.4 by Sebastian Bergmann and contributors.

E.                                                                  2 / 2 (100%)

Time: 00:00.206, Memory: 32.00 MB

There was 1 error:

1) Tests\Feature\Jobs\PruneAuthTokensTest::testExpiredAuthTokenDeleted
Illuminate\Database\UniqueConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'jane@smith' for key 'user.user_email_unique' (Connection: mysql, SQL: insert into `user` (`firstname`, `lastname`, `email`, `password`, `institution`, `admin`, `updated_at`, `created_at`) values (Jane, Smith, jane@smith, 12345, me, 0, 2024-06-04 15:05:28, 2024-06-04 15:05:28))

/cdash/vendor/laravel/framework/src/Illuminate/Database/Connection.php:824
/cdash/vendor/laravel/framework/src/Illuminate/Database/Connection.php:783
/cdash/vendor/laravel/framework/src/Illuminate/Database/Connection.php:576
/cdash/vendor/laravel/framework/src/Illuminate/Database/Connection.php:540
/cdash/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/Processor.php:32
/cdash/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:3507
/cdash/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:1982
/cdash/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1333
/cdash/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1298
/cdash/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1137
/cdash/tests/Traits/CreatesUsers.php:33
/cdash/tests/Feature/Jobs/PruneAuthTokensTest.php:23

Caused by
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'jane@smith' for key 'user.user_email_unique'

/cdash/vendor/laravel/framework/src/Illuminate/Database/Connection.php:587
/cdash/vendor/laravel/framework/src/Illuminate/Database/Connection.php:816
/cdash/vendor/laravel/framework/src/Illuminate/Database/Connection.php:783
/cdash/vendor/laravel/framework/src/Illuminate/Database/Connection.php:576
/cdash/vendor/laravel/framework/src/Illuminate/Database/Connection.php:540
/cdash/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/Processor.php:32
/cdash/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:3507
/cdash/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:1982
/cdash/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1333
/cdash/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1298
/cdash/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1137
/cdash/tests/Traits/CreatesUsers.php:33
/cdash/tests/Feature/Jobs/PruneAuthTokensTest.php:23

ERRORS!
Tests: 2, Assertions: 2, Errors: 1.

@williamjallen williamjallen added this to the v3.5 milestone Jun 5, 2024
@williamjallen williamjallen enabled auto-merge June 5, 2024 14:32
@williamjallen williamjallen added this pull request to the merge queue Jun 5, 2024
Merged via the queue into Kitware:master with commit a886931 Jun 5, 2024
6 checks passed
@williamjallen williamjallen deleted the conflicting-test-emails branch June 5, 2024 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants