The test was wiping the database
  • Telegram
  • Debugging
  • Testlar
  • Kesh

The test was wiping the database

50
Today I hardened the habits project from every side. It was a long day, so I will write about the most important parts. The first one is the most dangerous. The project has a quick check test: it runs and verifies that the main things work. After finishing, it is supposed to clean up after itself. When I wrote it, I had used a "drop the database" command. Locally that is harmless. But this test could also run on the server — and in that case it would wipe the real database. I noticed it by accident and fixed it immediately: the test now clears only the records it created, not the whole database. The second one: a sign-in failure had come back in the Mini App. This was a problem I had fixed before, and a later change had reintroduced it. So this time, along with the fix, I wrote the reasoning into a separate file — so that next time I remember why it was done that way. The third one: Telegram's built-in browser caches pages very aggressively. You ship a new version and the user still sees the old one. The solution: a version number is added to the page address, so when the version changes the address changes too and the cache no longer applies. The rest were smaller: seven bugs found by testing in a browser, and a heat map that appeared empty. The lesson of the day: tests are code too, and they can be dangerous as well.