MCPcopy
hub / github.com/simstudioai/sim / test

Function test

apps/sim/lib/data-drains/destinations/bigquery.ts:292–308  ·  view source on GitHub ↗

* 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 })

Source from the content-addressed store, hash-verified

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)

Callers

nothing calls this directly

Calls 4

parseServiceAccountFunction · 0.90
textMethod · 0.80
buildJwtFunction · 0.70
getAccessTokenFunction · 0.70

Tested by

no test coverage detected