(t *testing.T)
| 173 | } |
| 174 | |
| 175 | func openPostgresTestSchema(t *testing.T) (context.Context, string) { |
| 176 | t.Helper() |
| 177 | |
| 178 | baseDSN := strings.TrimSpace(os.Getenv("QUI_TEST_POSTGRES_DSN")) |
| 179 | if baseDSN == "" { |
| 180 | t.Skip("QUI_TEST_POSTGRES_DSN not set") |
| 181 | } |
| 182 | |
| 183 | ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) |
| 184 | t.Cleanup(cancel) |
| 185 | |
| 186 | adminPool, err := pgxpool.New(ctx, baseDSN) |
| 187 | require.NoError(t, err) |
| 188 | t.Cleanup(adminPool.Close) |
| 189 | |
| 190 | schemaName := fmt.Sprintf("qui_test_%d", time.Now().UnixNano()) |
| 191 | _, err = adminPool.Exec(ctx, "CREATE SCHEMA "+quoteIdent(schemaName)) |
| 192 | require.NoError(t, err) |
| 193 | t.Cleanup(func() { |
| 194 | _, _ = adminPool.Exec(context.Background(), fmt.Sprintf("DROP SCHEMA %s CASCADE", quoteIdent(schemaName))) |
| 195 | }) |
| 196 | |
| 197 | return ctx, dsnWithSearchPath(t, baseDSN, schemaName) |
| 198 | } |
| 199 | |
| 200 | func dsnWithSearchPath(t *testing.T, dsn string, schema string) string { |
| 201 | t.Helper() |
no test coverage detected