Deploy to K8s / deploy (push) Successful in 20s
Go (go/) becomes the primary implementation. The original Python version moves to legacy/ and is kept runnable; new features are still built in both (see the Dual implementation rule in CLAUDE.md). - git mv app.py, scripts/, templates/, tests/, pyproject.toml, uv.lock and build/ into legacy/ - Makefile: Python targets point at legacy/, venv in legacy/.venv, CREDENTIALS_PATH exported for the root .secret/ file - CI and make image build the Python image with legacy/ as context; the Makefile is no longer copied into the image - legacy/.dockerignore moved to the context root so it takes effect - CLAUDE.md, docs/README.md, Go comments, fixture README, capture script and VS Code launch config updated to the new layout Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
package matching
|
|
|
|
// Expected values verified against legacy/scripts/match_payments.py on 2026-05-06:
|
|
//
|
|
// PYTHONPATH=legacy/scripts:legacy python3 -c '
|
|
// from match_payments import format_date
|
|
// for v in [None, "", 44197, 44197.5, "2026-04-15", "garbage", " 2026-04-15 "]:
|
|
// print(repr(format_date(v)))
|
|
// '
|
|
//
|
|
// Output:
|
|
//
|
|
// ''
|
|
// ''
|
|
// '2021-01-01'
|
|
// '2021-01-01'
|
|
// '2026-04-15'
|
|
// 'garbage'
|
|
// '2026-04-15'
|
|
|
|
import "testing"
|
|
|
|
func TestFormatDate(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
cases := []struct {
|
|
name string
|
|
input any
|
|
want string
|
|
}{
|
|
{name: "nil", input: nil, want: ""},
|
|
{name: "empty string", input: "", want: ""},
|
|
{name: "serial int", input: int(44197), want: "2021-01-01"},
|
|
{name: "serial float fractional", input: float64(44197.5), want: "2021-01-01"},
|
|
{name: "already formatted", input: "2026-04-15", want: "2026-04-15"},
|
|
{name: "garbage string", input: "garbage", want: "garbage"},
|
|
{name: "padded date string trimmed", input: " 2026-04-15 ", want: "2026-04-15"},
|
|
}
|
|
|
|
for _, tc := range cases {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
t.Parallel()
|
|
got := FormatDate(tc.input)
|
|
if got != tc.want {
|
|
t.Errorf("FormatDate(%v) = %q, want %q", tc.input, got, tc.want)
|
|
}
|
|
})
|
|
}
|
|
}
|