createPgDriver creates and opens a PostgreSQL driver for the specified database. This is a shared helper function for tests.
(ctx context.Context, host, port, database string)
| 11 | // createPgDriver creates and opens a PostgreSQL driver for the specified database. |
| 12 | // This is a shared helper function for tests. |
| 13 | func createPgDriver(ctx context.Context, host, port, database string) (*pgdb.Driver, error) { |
| 14 | driver := &pgdb.Driver{} |
| 15 | config := db.ConnectionConfig{ |
| 16 | DataSource: &storepb.DataSource{ |
| 17 | Type: storepb.DataSourceType_ADMIN, |
| 18 | Username: "postgres", |
| 19 | Host: host, |
| 20 | Port: port, |
| 21 | Database: database, |
| 22 | }, |
| 23 | Password: "root-password", |
| 24 | ConnectionContext: db.ConnectionContext{ |
| 25 | EngineVersion: "16.0", |
| 26 | DatabaseName: database, |
| 27 | }, |
| 28 | } |
| 29 | _, err := driver.Open(ctx, storepb.Engine_POSTGRES, config) |
| 30 | if err != nil { |
| 31 | return nil, err |
| 32 | } |
| 33 | return driver, nil |
| 34 | } |
no test coverage detected