()
| 39 | : undefined); |
| 40 | |
| 41 | export const isDbAvailable = async (): Promise<boolean> => { |
| 42 | if (availabilityCache !== null) { |
| 43 | return availabilityCache; |
| 44 | } |
| 45 | |
| 46 | if (explicitTestDatabaseUrl() === undefined) { |
| 47 | availabilityCache = false; |
| 48 | |
| 49 | return availabilityCache; |
| 50 | } |
| 51 | |
| 52 | try { |
| 53 | await db.execute(sql`SELECT 1`); |
| 54 | availabilityCache = true; |
| 55 | } catch { |
| 56 | availabilityCache = false; |
| 57 | } |
| 58 | |
| 59 | return availabilityCache; |
| 60 | }; |
| 61 | |
| 62 | /** |
| 63 | * Skip-guard for integration tests. Use at the top of each test: |
no test coverage detected