forked from electric-sql/pglite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Related to electric-sql#369
- Loading branch information
Showing
3 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { PGlite } from '../src/pglite'; | ||
import { describe, it, expect } from 'vitest'; | ||
import { promises as fs } from 'fs'; | ||
|
||
describe('PGlite version reporting', () => { | ||
let pg: PGlite; | ||
|
||
beforeAll(async () => { | ||
pg = await PGlite.create({ dataDir: 'memory://test' }); | ||
}); | ||
|
||
afterAll(async () => { | ||
await pg.close(); | ||
}); | ||
|
||
it('should create PGLITE_VERSION file with correct content', async () => { | ||
const versionFilePath = '/tmp/pglite/base/PGLITE_VERSION'; | ||
const versionFileContent = await fs.readFile(versionFilePath, 'utf8'); | ||
const version = await pg.query<{ version: string }>('SELECT version()'); | ||
const expectedContent = `Created by: ${version.rows[0].version}`; | ||
expect(versionFileContent).toBe(expectedContent); | ||
}); | ||
|
||
it('should report correct version with SELECT VERSION()', async () => { | ||
const result = await pg.query<{ version: string }>('SELECT version()'); | ||
expect(result.rows[0].version).toContain('PGlite'); | ||
}); | ||
}); |