Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

fix(test): backdate UserBalance.updatedAt in test_block_credit_reset (#12236)

Zamil Majdy1c51dd18aa70
diff --git a/autogpt_platform/backend/backend/data/credit_test.py b/autogpt_platform/backend/backend/data/credit_test.py
index cb5973c74f..0f5cd152a0 100644
--- a/autogpt_platform/backend/backend/data/credit_test.py
+++ b/autogpt_platform/backend/backend/data/credit_test.py
@@ -178,9 +178,13 @@ async def test_block_credit_reset(server: SpinTestServer):
assert month2_balance == 1100 # Balance persists, no reset
# Now test the refill behavior when balance is low
- # Set balance below refill threshold
+ # Set balance below refill threshold and backdate updatedAt to month2 so
+ # the month3 refill check sees a different (month2 → month3) transition.
+ # Without the explicit updatedAt, Prisma sets it to real-world NOW which
+ # may share the same calendar month as the mocked month3, suppressing refill.
await UserBalance.prisma().update(
- where={"userId": DEFAULT_USER_ID}, data={"balance": 400}
+ where={"userId": DEFAULT_USER_ID},
+ data={"balance": 400, "updatedAt": month2},
)
# Create a month 2 transaction to update the last transaction time