From 8566e7c0bdb7aaea3d07b720b7b77448ff923609 Mon Sep 17 00:00:00 2001 From: Emil Lerch Date: Wed, 30 Sep 2026 10:57:15 -0700 Subject: [PATCH] suppress log messages for tests --- src/commands/contributions.zig | 5 ++++- src/service.zig | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/commands/contributions.zig b/src/commands/contributions.zig index 0b23a40..c63c0a3 100644 --- a/src/commands/contributions.zig +++ b/src/commands/contributions.zig @@ -247,6 +247,7 @@ //! decided from the Lot.maturity_date field, not from the file's form. const std = @import("std"); +const builtin = @import("builtin"); const zfin = @import("../root.zig"); const cli = @import("common.zig"); const git = @import("../git.zig"); @@ -732,7 +733,9 @@ fn loadDividendCredits( for (holdings) |h| { if (divs.contains(h.symbol)) continue; fetchDividendsInto(arena, svc, &divs, h.symbol, fetch_opts) catch |err| { - std.log.scoped(.contributions).warn("{s}: dividends unavailable ({t}); a dividend it paid into {s} will count as a contribution", .{ h.symbol, err, h.account }); + // The degradation test reaches this on purpose and asserts the + // outcome instead. + if (!builtin.is_test) std.log.scoped(.contributions).warn("{s}: dividends unavailable ({t}); a dividend it paid into {s} will count as a contribution", .{ h.symbol, err, h.account }); }; } return dividendCredits(arena, holdings, w, &divs); diff --git a/src/service.zig b/src/service.zig index 69f7114..78734f5 100644 --- a/src/service.zig +++ b/src/service.zig @@ -756,7 +756,9 @@ pub const DataService = struct { // collapsing it, and do not negative-cache - nothing is // wrong with the symbol. if (err == DataError.NoApiKey) { - log.warn("{s}: {s} unavailable: no API key configured", .{ symbol, @tagName(data_type) }); + // Tests reach this on purpose - there is no key in the test + // environment - and assert the typed error instead. + if (!builtin.is_test) log.warn("{s}: {s} unavailable: no API key configured", .{ symbol, @tagName(data_type) }); return DataError.NoApiKey; } // Only NotFound (provider says "this symbol genuinely has