* Probes table existence, IAM access, and credential validity in a single * `tables.get` call. `fields=id` minimises response size — we only care * whether the call succeeds, not the payload.
({ config, credentials, signal })
| 290 | * whether the call succeeds, not the payload. |
| 291 | */ |
| 292 | async test({ config, credentials, signal }) { |
| 293 | const account = parseServiceAccount(credentials.serviceAccountJson) |
| 294 | const jwt = buildJwt(account) |
| 295 | const token = await getAccessToken(jwt) |
| 296 | const url = `https://bigquery.googleapis.com/bigquery/v2/projects/${encodeURIComponent(config.projectId)}/datasets/${encodeURIComponent(config.datasetId)}/tables/${encodeURIComponent(config.tableId)}?fields=id` |
| 297 | const perAttempt = AbortSignal.any([signal, AbortSignal.timeout(PER_ATTEMPT_TIMEOUT_MS)]) |
| 298 | const response = await fetch(url, { |
| 299 | headers: { Authorization: `Bearer ${token}` }, |
| 300 | signal: perAttempt, |
| 301 | }) |
| 302 | if (!response.ok) { |
| 303 | const text = await response.text().catch(() => '') |
| 304 | throw new Error(`BigQuery probe failed (HTTP ${response.status}): ${text}`) |
| 305 | } |
| 306 | /** Drain the success body so undici can return the socket to the keep-alive pool. */ |
| 307 | await response.text().catch(() => '') |
| 308 | }, |
| 309 | |
| 310 | openSession({ config, credentials }) { |
| 311 | const account = parseServiceAccount(credentials.serviceAccountJson) |
nothing calls this directly
no test coverage detected