Replies: 1 comment 1 reply
-
I would guess that you are not selecting an in-memory database during test. You use the following code to select a profile: You can check what db your tests are using by running Once you've determined that it actually is using an independent in-memory db for each test, we can take a look at what else might be causing these issues. It's also possible that some tests have internal race conditions, and some kind of cleanup got executed before the test actually completed. |
Beta Was this translation helpful? Give feedback.
-
I tell you my case that has me a bit “crazy”. The source code of the project I am going to talk about is here.
The problem is that when I do the Rocket tests for some reason it seems to mix one test with another and, possibly because of a race condition, it fails me. It is something that happens from time to time, sometimes never, sometimes several times in a row.
If we look at this code we see that what it has is a rocket function that raises the service, by default as it is not passing any configuration it does it in
:memory:
.Rocket function (code fragment)
So to test this what I do is to raise a client with
let client = Client::tracked(rocket()).await.unwrap();
and from there I start making requests, it is supposed to give me a client connected to an in-memory DB that is clean and independent, but it seems that it does not because sometimes it fails. For example here, here, here, here and here.Whether it is asynchronous or synchronous should not have any influence since each test is supposed to be independent and in fact it is designed to be so. Can you think of any idea why it might be failing? Could it be a rare bug?
Beta Was this translation helpful? Give feedback.
All reactions