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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Eventual Consistency in integration tests #34

Open
Melethainiel opened this issue Apr 6, 2024 · 0 comments
Open

[Question] Eventual Consistency in integration tests #34

Melethainiel opened this issue Apr 6, 2024 · 0 comments

Comments

@Melethainiel
Copy link

Hey @amantinband !
First of all, thank you for this amazing template 馃憤

I have a question on the EventualConsistencyMiddleware during integration testing.
Due to the transaction being commit after the request has return ok200, when testing for duplication how do you handle that ?

Do you add a delay in the test like below ? Or do you do something else ?
Thank you again !
Take care

   public async Task Register_RegisterIdentity_WhenEmailIsAlreadyUsed()
   {
      // Arrange
      var identity = _faker.Generate();
      await _identityRequest.RegisterAsync(identity);
      await Task.Delay(100); // Let the transaction being commited ?
      // Act
      var response = await _identityRequest.RegisterAsync(identity);

      // Assert
      response.IsSuccessStatusCode.Should().BeFalse();
      response.StatusCode.Should().Be(HttpStatusCode.BadRequest);
      var problem = await response.Error!.GetContentAsAsync<ProblemDetails>();
      problem!.Detail.Should().Be(IdentityError.EmailAlreadyUsed(identity.Email).Description);
   }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant