All checks were successful
Deploy to K8s / deploy (push) Successful in 11s
- io/attendance: CSV-over-public-URL client + Fake for adult/junior tabs - io/drive: Drive v3 modifiedTime client + Fake - io/sheets: Sheets v4 client (GetValues/AppendValues/BatchUpdateValues/ WriteHeader/SortByDateColumn) + Fake with call-capture - io/cache: Drive-modifiedTime-gated FileCache; two TTL knobs; atomic writes; generic Get[T]; Python-compatible JSON format; Flush() - io/fio: Client interface backed by Fio REST API (apiClient) and HTML scraper (transparentClient); Fake; testdata fixtures - membership/sources: NewSources wires attendance CSV + Sheets + cache into LoadAdults/LoadJuniors/LoadTransactions/LoadExceptions; Czech month parsing + merged-month maps - banksync: SyncToSheets (SHA-256 dedup, optional sort) and InferPayments ([?] review prefix, dry-run) — tested with fakes - cmd/fuj: sync and infer subcommands wired; fees and reconcile use real NewSources; go.mod gains google.golang.org/api + x/net - gofumpt extra-rules applied across all packages; lint clean Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
73 lines
1.8 KiB
Go
73 lines
1.8 KiB
Go
package membership
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"fuj-management/go/internal/domain/reconcile"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
type fakeSources struct {
|
|
members []reconcile.Member
|
|
months []string
|
|
txns []reconcile.Transaction
|
|
exceptions map[reconcile.ExceptionKey]reconcile.Exception
|
|
}
|
|
|
|
func (f fakeSources) LoadAdults(_ context.Context) ([]reconcile.Member, []string, error) {
|
|
return f.members, f.months, nil
|
|
}
|
|
|
|
func (f fakeSources) LoadJuniors(_ context.Context) ([]reconcile.Member, []string, error) {
|
|
return nil, nil, nil
|
|
}
|
|
|
|
func (f fakeSources) LoadTransactions(_ context.Context) ([]reconcile.Transaction, error) {
|
|
return f.txns, nil
|
|
}
|
|
|
|
func (f fakeSources) LoadExceptions(_ context.Context) (map[reconcile.ExceptionKey]reconcile.Exception, error) {
|
|
return f.exceptions, nil
|
|
}
|
|
|
|
func TestReconcileReport(t *testing.T) {
|
|
t.Parallel()
|
|
s := fakeSources{
|
|
members: []reconcile.Member{
|
|
{Name: "Alice", Tier: "A", Fees: map[string]reconcile.FeeData{
|
|
"2026-04": {Expected: 700, Attendance: 3},
|
|
}},
|
|
},
|
|
months: []string{"2026-04"},
|
|
txns: []reconcile.Transaction{
|
|
{
|
|
Date: "2026-04-10", Amount: 700, Person: "Alice", Purpose: "2026-04",
|
|
Sender: "Alice Bank", Message: "fee",
|
|
},
|
|
},
|
|
exceptions: map[reconcile.ExceptionKey]reconcile.Exception{},
|
|
}
|
|
|
|
var buf bytes.Buffer
|
|
if err := ReconcileReport(context.Background(), s, 2026, &buf); err != nil {
|
|
t.Fatalf("unexpected error: %v", err)
|
|
}
|
|
got := buf.String()
|
|
if !strings.Contains(got, "PAYMENT RECONCILIATION REPORT") {
|
|
t.Error("missing report header")
|
|
}
|
|
if !strings.Contains(got, "OK") {
|
|
t.Errorf("expected 'OK' for fully-paid Alice, got:\n%s", got)
|
|
}
|
|
}
|
|
|
|
func TestReconcileReportStubErrors(t *testing.T) {
|
|
t.Parallel()
|
|
var buf bytes.Buffer
|
|
err := ReconcileReport(context.Background(), NewStubSources(), 2026, &buf)
|
|
if err == nil {
|
|
t.Fatal("expected error from stub, got nil")
|
|
}
|
|
}
|