ElektraInitiative / PermaplanT

https://www.permaplant.net
BSD 3-Clause "New" or "Revised" License
16 stars 13 forks source link

Fix backend tests #1223

Open horenso opened 7 months ago

horenso commented 7 months ago

Describe the Bug

There are a few backend tests that sometimes fail. I already fixed one in this commit. The reason this happens is that the backend tests reuse the development database. Then some tests make a get request, which gives you a paged result (10 out of x results say), but the test assums that the result set is complete. It's worth noting that the backend tests work with transaction rollback, the tests don't alter the databse but see the state.

Steps to Reproduce the Problem

Have data in the database, use make test-backend or cargo t in the backend directory.

Expected Result

Tests should always work. We could either make the tests work even with data already in the database. (See above my adhoc fix) or we make the tests use an empty database.

Actual Result

Test fail sometimes, and the developer needs to run make reset-databse to clear the database.

PermaplanT version

master

Operating System

Linux

Browser

Independent (backend issue)

Versions of other relevant software/extensions

No response

Additional info/logs

No response

markus2330 commented 7 months ago

I think this is a duplicate from #589?

The problem is that there are so many different setups, so it is hard to tell how to cleanup the database. The "ideal" solution via a REST call was considered to be not worth the effort.