Skip to content

Commit 05dd9e6

Browse files
fix(tests): use Sequence for UserFactory username to avoid duplicates
Faker("user_name") can generate collisions when many users are created in a single test, causing UniqueViolation on the username field.
1 parent 643420e commit 05dd9e6

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/firefighter/incidents/factories.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Meta:
2626

2727
name = Faker("name") # type: ignore[no-untyped-call]
2828
email = Faker("email") # type: ignore[no-untyped-call]
29-
username = Faker("user_name") # type: ignore[no-untyped-call]
29+
username = Sequence(lambda n: f"user_{n}") # type: ignore[no-untyped-call]
3030

3131

3232
class GroupFactory(DjangoModelFactory[Group]):

0 commit comments

Comments
 (0)