package sinks import ( "context" "testing" "gitea.maximumdirect.net/ejr/feedkit/config" "gitea.maximumdirect.net/ejr/feedkit/event" ) func TestPostgresFactoryReturnsWorkingFactory(t *testing.T) { factory := PostgresFactory(testPostgresSchema()) if factory == nil { t.Fatalf("PostgresFactory() returned nil") } if _, err := factory(config.SinkConfig{}); err == nil { t.Fatalf("factory(config) expected parameter validation error") } } func testPostgresSchema() PostgresSchema { return PostgresSchema{ Tables: []PostgresTable{ { Name: "events", Columns: []PostgresColumn{ {Name: "event_id", Type: "TEXT", Nullable: false}, {Name: "emitted_at", Type: "TIMESTAMPTZ", Nullable: false}, }, PrimaryKey: []string{"event_id"}, PruneColumn: "emitted_at", }, }, MapEvent: func(_ context.Context, e event.Event) ([]PostgresWrite, error) { return []PostgresWrite{ { Table: "events", Values: map[string]any{ "event_id": e.ID, "emitted_at": e.EmittedAt, }, }, }, nil }, } }