File size: 807 Bytes
4bbfe8b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { expect, test } from "bun:test"
import { R2SqlQueryError } from "./r2-sql"

test("includes the transport failure in the message used by sync logging", () => {
  const cause = new DOMException("The operation timed out.", "TimeoutError")
  const error = new R2SqlQueryError({ message: "Failed to run R2 SQL stats query", cause })

  expect(error.message).toBe("Failed to run R2 SQL stats query: TimeoutError: The operation timed out.")
  expect(error.cause).toBe(cause)
})

test("preserves an R2 response error and request details", () => {
  const error = new R2SqlQueryError({ message: "R2 SQL stats query failed", status: 400, requestId: "test-request" })

  expect(error.message).toBe("R2 SQL stats query failed")
  expect(error.status).toBe(400)
  expect(error.requestId).toBe("test-request")
})