fix(go/fio): nested-table early exit + non-padded date parsing
All checks were successful
Deploy to K8s / deploy (push) Successful in 9s
All checks were successful
Deploy to K8s / deploy (push) Successful in 9s
extractSecondTableRows tracked a boolean inTarget flag and exited on
the first </table> token while inside the target. Any nested <table>
(e.g. pagination markup in the real Fio page) would cause an early
return before reading any data rows, explaining the 0-transaction report.
Fixed by tracking targetDepth instead: depth increments on every <table>
inside the target and we only return when it reaches 0 again.
parseCzechDate also only tried zero-padded layouts ("02.01.2006").
The real Fio transparent page emits non-padded dates ("7.5.2026");
added "2.1.2006" and "2/1/2006" as the preferred layouts.
Also adds a dry-run diagnostic line ("fetched N transaction(s) from Fio")
so the fetch vs dedup split is visible without reading logs.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -95,6 +95,8 @@ func TestParseCzechDate(t *testing.T) {
|
||||
cases := []struct{ in, want string }{
|
||||
{"10.04.2026", "2026-04-10"},
|
||||
{"10/04/2026", "2026-04-10"},
|
||||
{"7.5.2026", "2026-05-07"}, // non-padded — real Fio transparent page format
|
||||
{"3.12.2025", "2025-12-03"}, // non-padded single-digit day, double-digit month
|
||||
{"", ""},
|
||||
{"invalid", ""},
|
||||
}
|
||||
@@ -105,6 +107,22 @@ func TestParseCzechDate(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestExtractSecondTableRows_NestedTable(t *testing.T) {
|
||||
// Regression: a nested <table> inside the target must not cause early exit.
|
||||
html := `<table class="table"><tr><td>nav</td></tr></table>
|
||||
<table class="table">
|
||||
<thead><tr><th>Date</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td>7.5.2026</td><td><table><tr><td>nested</td></tr></table></td></tr>
|
||||
<tr><td>6.5.2026</td><td></td></tr>
|
||||
</tbody>
|
||||
</table>`
|
||||
rows := extractSecondTableRows([]byte(html))
|
||||
if len(rows) != 2 {
|
||||
t.Errorf("want 2 data rows, got %d: %v", len(rows), rows)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseCzechAmount(t *testing.T) {
|
||||
cases := []struct {
|
||||
in string
|
||||
|
||||
Reference in New Issue
Block a user