Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyuhang0 committed Feb 21, 2024
1 parent cda5d6e commit 4c0120d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions integration-test/type.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,28 @@ describe('types', () => {

expect(JSON.stringify(rows[0])).toEqual(JSON.stringify(fullTypeResult))
})

test('test raw bytes as input', async () => {
const con = connect({ url: databaseURL, database: database, fetch })
const tableName = 'raw_bytes'
const tableDDL = `
create table ${tableName} (
bytes blob
)`
await con.execute(`DROP table IF EXISTS ${tableName}`)
await con.execute(tableDDL)

const input = 'FSDF'
const inputAsBuffer = Buffer.from(input, 'base64')
await con.execute(`insert into ${tableName} values (?)`, [inputAsBuffer])
const rows = (await con.execute(`select * from ${tableName}`)) as Row[]

console.log(rows)
expect(rows.length).toEqual(1)
const outputRaw = rows[0]['bytes']
const outputAsBuffer = Buffer.from(outputRaw)
const output = outputAsBuffer.toString('base64')

expect(input).toEqual(output)
})
})
Empty file added test.js
Empty file.

0 comments on commit 4c0120d

Please sign in to comment.