From 6d72c85766a8355e1d660ff0c19b43e93faad4d8 Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Sat, 1 Aug 2026 14:49:15 +0200 Subject: add testing/pgruntime Testing pgruntime has quickly turned out to be a nightmare, because so many parts of the test logic are not easily reproducible (e.g. `stopDBIfLingering`). I decided to not waste a bunch of time testing code that is relatively compact and easy to verify by careful examination, and that is unlikely to change a lot in the future. --- pgruntime/connector.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'pgruntime/connector.go') diff --git a/pgruntime/connector.go b/pgruntime/connector.go index 92780f6..5276a26 100644 --- a/pgruntime/connector.go +++ b/pgruntime/connector.go @@ -164,10 +164,12 @@ func resetTestDatabase(ctx context.Context, db gsql.Handle, params testSetupPara } // truncate all tables at once - query = fmt.Sprintf(`TRUNCATE %s RESTART IDENTITY CASCADE`, strings.Join(quotedTableNames, ", ")) - _, err = execQuery(ctx, db, query, nil) - if err != nil { - return fmt.Errorf("during %s: %w", query, err) + if len(quotedTableNames) > 0 { + query = fmt.Sprintf(`TRUNCATE %s RESTART IDENTITY CASCADE`, strings.Join(quotedTableNames, ", ")) + _, err = execQuery(ctx, db, query, nil) + if err != nil { + return fmt.Errorf("during %s: %w", query, err) + } } return nil -- cgit v1.3.1