Files
Jan Novak 6465e2a221
All checks were successful
Deploy to K8s / deploy (push) Successful in 11s
feat(go): IO layer behind interfaces (M4)
- 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>
2026-05-07 01:05:59 +02:00

54 lines
1.6 KiB
Go

package sheets
import (
"context"
"fmt"
)
// Fake is an in-memory replacement for Client used in tests.
// Values maps a "<spreadsheetID>/<a1Range>" key to pre-seeded rows.
type Fake struct {
// Values maps "spreadsheetID/range" → rows returned by GetValues.
Values map[string][][]any
// Appended collects rows passed to AppendValues for assertion.
Appended []AppendCall
// BatchUpdated collects calls to BatchUpdateValues.
BatchUpdated []BatchCall
}
// AppendCall records one AppendValues invocation.
type AppendCall struct {
SpreadsheetID string
Range string
Rows [][]any
}
// BatchCall records one BatchUpdateValues invocation.
type BatchCall struct {
SpreadsheetID string
Updates []ValueRange
}
func (f *Fake) GetValues(_ context.Context, spreadsheetID, a1Range string) ([][]any, error) {
key := spreadsheetID + "/" + a1Range
rows, ok := f.Values[key]
if !ok {
return nil, fmt.Errorf("sheets fake: no seed for %q", key)
}
return rows, nil
}
func (f *Fake) AppendValues(_ context.Context, spreadsheetID, a1Range string, rows [][]any) error {
f.Appended = append(f.Appended, AppendCall{SpreadsheetID: spreadsheetID, Range: a1Range, Rows: rows})
return nil
}
func (f *Fake) BatchUpdateValues(_ context.Context, spreadsheetID string, updates []ValueRange) error {
f.BatchUpdated = append(f.BatchUpdated, BatchCall{SpreadsheetID: spreadsheetID, Updates: updates})
return nil
}
func (f *Fake) WriteHeader(_ context.Context, _ string, _ []string) error { return nil }
func (f *Fake) SortByDateColumn(_ context.Context, _ string) error { return nil }