Skip to content

More tests & exports from pg-protocol #3436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/pg-esm-test/common-js-imports.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ const assert = require('node:assert')
const test = require('node:test')
const { describe, it } = test

const paths = ['pg', 'pg/lib/index.js', 'pg/lib/connection-parameters.js']
const paths = [
'pg',
'pg/lib/index.js',
'pg/lib/connection-parameters.js',
'pg-protocol/dist/messages.js',
'pg-native/lib/build-result.js',
]
for (const path of paths) {
describe(`importing ${path}`, () => {
it('works with require', () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/pg-esm-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"pg-cursor": "^2.14.1",
"pg-native": "^3.4.0",
"pg-pool": "^3.9.1",
"pg-query-stream": "^4.9.1"
"pg-query-stream": "^4.9.1",
"pg-protocol": "^1.9.0"
},
"author": "Brian M. Carlson <brian.m.carlson@gmail.com>",
"license": "MIT"
Expand Down
18 changes: 18 additions & 0 deletions packages/pg-esm-test/pg-protocol.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import protocol, { NoticeMessage, DatabaseError } from 'pg-protocol/dist/messages.js'
import { describe, it } from 'node:test'
import { strict as assert } from 'node:assert'

describe('pg-protocol', () => {
it('should export database error', () => {
assert.ok(DatabaseError)
})
it('should export protocol', () => {
assert.ok(protocol)
assert.ok(protocol.noData)
assert.ok(protocol.parseComplete)
assert.ok(protocol.NoticeMessage)
})
it('should export NoticeMessage from file in dist folder', () => {
assert.ok(NoticeMessage)
})
})
1 change: 1 addition & 0 deletions packages/pg-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
},
"files": [
"index.js",
"lib",
"esm"
]
}
2 changes: 1 addition & 1 deletion packages/pg-protocol/esm/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// ESM wrapper for pg-protocol
import protocol from '../dist/index.js'
import * as protocol from '../dist/index.js'

// Re-export all the properties
export const DatabaseError = protocol.DatabaseError
Expand Down
5 changes: 5 additions & 0 deletions packages/pg-protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
"import": "./esm/index.js",
"require": "./dist/index.js",
"default": "./dist/index.js"
},
"./dist/*": {
"import": "./dist/*",
"require": "./dist/*",
"default": "./dist/*"
}
},
"license": "MIT",
Expand Down