Go app for capturing and archiving HSA-eligible receipts: OIDC/PKCE auth against Authelia, SQLite storage with dual-write (filesystem + DB blob), mobile-first upload, and DB export. Adds AI receipt classification: a config.json catalog of people and categories (seeded into the DB on startup), a prompt builder that derives name-order/initial variants from the data (with same-surname ambiguity handling), and an Anthropic tool-use client behind POST /classify. Tests run against a mock endpoint; a live integration test is env-gated to the cheapest model. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
37 lines
795 B
Go
37 lines
795 B
Go
package receipt
|
|
|
|
import "testing"
|
|
|
|
func TestParseAmountCents(t *testing.T) {
|
|
ok := []struct {
|
|
in string
|
|
want int64
|
|
}{
|
|
{"12.34", 1234},
|
|
{"0.99", 99},
|
|
{"100", 10000},
|
|
{"12.3", 1230},
|
|
{"12", 1200},
|
|
{"1234.00", 123400},
|
|
{"$12.34", 1234},
|
|
{" 12.34 ", 1234},
|
|
{"1,234.56", 123456},
|
|
}
|
|
for _, tc := range ok {
|
|
got, err := ParseAmountCents(tc.in)
|
|
if err != nil {
|
|
t.Errorf("ParseAmountCents(%q) unexpected error: %v", tc.in, err)
|
|
continue
|
|
}
|
|
if got != tc.want {
|
|
t.Errorf("ParseAmountCents(%q) = %d, want %d", tc.in, got, tc.want)
|
|
}
|
|
}
|
|
|
|
bad := []string{"", "abc", "12.345", "-5.00", "0", "0.00", "12.3.4", "."}
|
|
for _, in := range bad {
|
|
if _, err := ParseAmountCents(in); err == nil {
|
|
t.Errorf("ParseAmountCents(%q) expected error, got nil", in)
|
|
}
|
|
}
|
|
}
|