package sheets import ( "context" "fmt" ) // Fake is an in-memory replacement for Client used in tests. // Values maps a "/" 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 }