Gonçalo Rodrigues 40c8632c7e fix(finance): fix 3 store bugs found by integration tests; add store_integration_test.go (#35)
The integration tests (testcontainers + mongo:7) exposed three real bugs:

1. deleteAllUserData filtered with bson.ObjectID on collections that store
   user_id as a plain string (Account, Goal, Property, etc.) — none of them
   were actually deleted. Fixed by using the original string userID for those
   collections; only finance_sessions (AuthSession.UserID is ObjectID) keeps
   the ObjectID filter.

2. consumeInvite correctly sets used_at, but the test was calling
   getInviteByToken afterwards and expecting the invite back — that query
   intentionally excludes used invites ($exists: false). Fixed the assertion
   to check that the token is no longer redeemable (nil return = correct).

3. createEvent stored GoalItems as null when the slice was nil; subsequent
   $push on a null field fails in MongoDB. Fixed by initialising GoalItems
   to []EventGoal{} before insert so the field is always an array.

Combined unit + integration coverage: 64.7% → 79.8%

Co-authored-by: Gonçalo Rodrigues <guga@Goncalos-MacBook-Pro.local>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-20 15:15:03 +01:00
..
2026-06-13 11:25:23 +01:00
2026-06-13 11:25:23 +01:00
2026-06-13 11:25:23 +01:00