test: mock AnthropicClient in analyze tests to prevent live API calls

This commit is contained in:
Kazuma
2026-06-08 12:08:37 -04:00
parent 76c2a671f4
commit ad1c3fe3c9
31 changed files with 415 additions and 171 deletions
+2 -5
View File
@@ -19,10 +19,8 @@ export class FinanceController {
app.get('/api/finance/market-context', this.marketContext.bind(this));
}
private async portfolio(_req: FastifyRequest, reply: FastifyReply) {
if (!this.repo.exists()) return reply.code(404).send({ error: 'portfolio.json not found' });
const { holdings } = this.repo.read();
private async portfolio(_req: FastifyRequest, _reply: FastifyReply) {
const { holdings } = this.repo.exists() ? this.repo.read() : { holdings: [] };
let personalFinance = null;
if (process.env.SIMPLEFIN_ACCESS_URL) {
@@ -58,7 +56,6 @@ export class FinanceController {
private async removeHolding(req: FastifyRequest, reply: FastifyReply) {
const ticker = (req.params as { ticker: string }).ticker.toUpperCase();
if (!this.repo.exists()) return reply.code(404).send({ error: 'portfolio.json not found' });
const removed = this.repo.remove(ticker);
if (!removed) return reply.code(404).send({ error: 'Holding not found' });