feat(api): initialize account with starting balance

This commit is contained in:
Stevan Freeborn
2026-02-14 06:46:05 -06:00
parent ed7e25961c
commit 6190470fe2
3 changed files with 21 additions and 0 deletions
@@ -222,6 +222,7 @@ public class AddTests(TestApi testApi) : IntegrationTest(testApi)
var newAccountId = "newAccountId";
var newAccountName = "New Account";
var expectedBalance = 100;
using var request = HttpRequestBuilder.New()
.Post(AddUri)
@@ -231,6 +232,8 @@ public class AddTests(TestApi testApi) : IntegrationTest(testApi)
plaidInstitutionId = ((PlaidMetadata)institution.Metadata!).PlaidId,
plaidAccountId = newAccountId,
plaidAccountName = newAccountName,
accountCurrentBalance = expectedBalance,
accountAvailableBalance = expectedBalance,
})
.Build();
@@ -242,6 +245,9 @@ public class AddTests(TestApi testApi) : IntegrationTest(testApi)
async (context, ct) => await context.Set<User>()
.Include(u => u.Accounts)
.ThenInclude(a => a.Metadata)
.Include(u => u.Accounts)
.ThenInclude(a => a.Balances)
.AsSplitQuery()
.FirstAsync(u => u.Id == user.Id, ct),
TestContext.Current.CancellationToken
);
@@ -253,5 +259,12 @@ public class AddTests(TestApi testApi) : IntegrationTest(testApi)
((PlaidAccountMetadata)a.Metadata).PlaidId == newAccountId &&
((PlaidAccountMetadata)a.Metadata).PlaidName == newAccountName
);
updatedUser.Accounts.First()
.Balances.Should().ContainSingle(
b => b.AccountId == updatedUser.Accounts.First().Id &&
b.Current == expectedBalance &&
b.Available == expectedBalance
);
}
}