beyond-all-reason / teiserver

Middleware server for online gaming
https://www.beyondallreason.info/
MIT License
55 stars 53 forks source link

Clear cache users between tests #342

Open geekingfrog opened 3 months ago

geekingfrog commented 3 months ago

This must be done for data cases as well as server cases. Because most of the querying logic rely under the hood on the caches, when someone creates a user, it won't be persisted to the DB after the test, but the cache will not be rolled back.

jauggy commented 3 months ago

I tested and it worked with this test: https://github.com/beyond-all-reason/teiserver/blob/f6421ac748e1a215d61959cc9fafea6144717288/test/teiserver/common/clear_db_each_test.exs

Would be better if some sort of test was included in this PR.

geekingfrog commented 3 months ago

I've added a test in f543bccb7bd2e738029595369d421cf452d988dd. Not sure of its value but it's something at least.

jauggy commented 3 months ago

Yeah I was thinking of the add user test that caused me to find the bug in the first place.

geekingfrog commented 3 months ago

Alright, I amended the commit and ended up using your test file. Not the biggest fan, but it's a start and definitely better than nothing.

geekingfrog commented 3 months ago

I'm going to hold off merging that, there's something fishy going on with some tests :( async + global caches => weird shit happening