corndel-swe / topsify

A global music streaming app
0 stars 1 forks source link

Bug in exercise 7? #19

Open nimonian opened 2 months ago

nimonian commented 2 months ago

I hit a very curious issue when doing the Topsify exercise 7a & 7b which is probably worth sharing with you.

It could be something little from my side I am missing but I ran into a weird issue with exercises 7a (insert) and 7b (update). When I run the tests, it seems to wipe out all the entries in the table before inserting new ones 😅.

This means you lose the existing users, and to pass, you have to hardcode the user ID for the insert, plus you don’t get the correct user for the update as it has been removed.

The issue only happens when running the tests. If I use the report CLI command (sqlite3 db/db.sqlite < exercises/7a.sql > reports/7a.txt), everything works as expected and can see the changes for both.

I’ve tried running the SQL in the SQLite shell, and it works fine there, so I’m a bit stumped. Sorry if I’m missing something obvious, but I’m not sure what’s causing it.

nimonian commented 2 months ago

Yep, replicated

image

How bizarre - looking into it

nimonian commented 2 months ago

Ok we have tests/setup.sh which runs db/reset.sql and also ./reset.sh which runs db/reset.sql and db/seeds/users.sql

That's pretty confounding - not sure how it ended up that way but probably just due to how the exercises evolved over time.

I'll see about rationalising it all and making sure my "solved" fork still works before opening a PR.

Charlie-robin commented 2 months ago

Cool you can ignore ./reset.sh that was added by me and isn't in the original repo.

So I didn't have to run those two commands when I was try debug the issue.

nimonian commented 2 months ago

That makes sense! Ha ha I did wonder why I'd done that XD

At any rate I think that test.sh runs reset.sql which drops and creates the users table without seeding it again which is a bummer. I'll have a crack at fixing it.