|
| 1 | +import { Firebolt } from "../../src/index"; |
| 2 | + |
| 3 | +const connectionParams = { |
| 4 | + auth: { |
| 5 | + username: process.env.FIREBOLT_USERNAME as string, |
| 6 | + password: process.env.FIREBOLT_PASSWORD as string |
| 7 | + }, |
| 8 | + database: process.env.FIREBOLT_DATABASE as string, |
| 9 | + engineName: process.env.FIREBOLT_ENGINE_NAME as string |
| 10 | +}; |
| 11 | + |
| 12 | +jest.setTimeout(100000); |
| 13 | + |
| 14 | +describe("bytea", () => { |
| 15 | + it("handles select bytea", async () => { |
| 16 | + const firebolt = Firebolt({ |
| 17 | + apiEndpoint: process.env.FIREBOLT_API_ENDPOINT as string |
| 18 | + }); |
| 19 | + |
| 20 | + const connection = await firebolt.connect(connectionParams); |
| 21 | + |
| 22 | + const statement = await connection.execute( |
| 23 | + "SELECT 'hello_world_123ツ\n\u0048'::bytea" |
| 24 | + ); |
| 25 | + |
| 26 | + const { data, meta } = await statement.fetchResult(); |
| 27 | + expect(meta[0].type).toEqual("bytea"); |
| 28 | + const row = data[0]; |
| 29 | + expect((row as unknown[])[0]).toEqual( |
| 30 | + Buffer.from("hello_world_123ツ\n\u0048") |
| 31 | + ); |
| 32 | + }); |
| 33 | + |
| 34 | + it("handles select null bytea", async () => { |
| 35 | + const firebolt = Firebolt({ |
| 36 | + apiEndpoint: process.env.FIREBOLT_API_ENDPOINT as string |
| 37 | + }); |
| 38 | + |
| 39 | + const connection = await firebolt.connect(connectionParams); |
| 40 | + |
| 41 | + const statement = await connection.execute("SELECT null::bytea"); |
| 42 | + |
| 43 | + const { data, meta } = await statement.fetchResult(); |
| 44 | + expect(meta[0].type).toEqual("nullable(bytea)"); |
| 45 | + const row = data[0]; |
| 46 | + expect((row as unknown[])[0]).toEqual(null); |
| 47 | + }); |
| 48 | +}); |
0 commit comments