Skip to content

Commit 5127f3a

Browse files
ConorNeobigmontz
andauthored
Make bolt agent an object in integration tests (#1092)
Co-authored-by: Antonio Barcélos <[email protected]>
1 parent 367efdf commit 5127f3a

File tree

6 files changed

+34
-21
lines changed

6 files changed

+34
-21
lines changed

packages/bolt-connection/src/connection/connection-channel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ export default class ChannelConnection extends Connection {
183183
/**
184184
* Send initialization message.
185185
* @param {string} userAgent the user agent for this driver.
186-
* @param {string} boltAgent the bolt agent for this driver.
186+
* @param {Object} boltAgent the bolt agent for this driver.
187187
* @param {Object} authToken the object containing auth information.
188188
* @param {boolean} waitReAuth whether ot not the connection will wait for re-authentication to happen
189189
* @return {Promise<Connection>} promise resolved with the current connection if connection is successful. Rejected promise otherwise.

packages/bolt-connection/src/connection/connection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export default class Connection {
9090
/**
9191
* Connect to the target address, negotiate Bolt protocol and send initialization message.
9292
* @param {string} userAgent the user agent for this driver.
93-
* @param {string} boltAgent the bolt agent for this driver.
93+
* @param {Object} boltAgent the bolt agent for this driver.
9494
* @param {Object} authToken the object containing auth information.
9595
* @param {boolean} shouldWaitReAuth whether ot not the connection will wait for re-authentication to happen
9696
* @return {Promise<Connection>} promise resolved with the current connection if connection is successful. Rejected promise otherwise.

packages/neo4j-driver-deno/lib/bolt-connection/connection/connection-channel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ export default class ChannelConnection extends Connection {
183183
/**
184184
* Send initialization message.
185185
* @param {string} userAgent the user agent for this driver.
186-
* @param {string} boltAgent the bolt agent for this driver.
186+
* @param {Object} boltAgent the bolt agent for this driver.
187187
* @param {Object} authToken the object containing auth information.
188188
* @param {boolean} waitReAuth whether ot not the connection will wait for re-authentication to happen
189189
* @return {Promise<Connection>} promise resolved with the current connection if connection is successful. Rejected promise otherwise.

packages/neo4j-driver-deno/lib/bolt-connection/connection/connection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export default class Connection {
9090
/**
9191
* Connect to the target address, negotiate Bolt protocol and send initialization message.
9292
* @param {string} userAgent the user agent for this driver.
93-
* @param {string} boltAgent the bolt agent for this driver.
93+
* @param {Object} boltAgent the bolt agent for this driver.
9494
* @param {Object} authToken the object containing auth information.
9595
* @param {boolean} shouldWaitReAuth whether ot not the connection will wait for re-authentication to happen
9696
* @return {Promise<Connection>} promise resolved with the current connection if connection is successful. Rejected promise otherwise.

packages/neo4j-driver/test/examples.test.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ describe('#integration examples', () => {
806806
try {
807807
await tempSession.run(
808808
"UNWIND ['Infinity Gauntlet', 'Mjölnir'] AS item " +
809-
'CREATE (:Product {id: 0, title: item})'
809+
'CREATE (:Product {id: 0, title: item})'
810810
)
811811
} finally {
812812
await tempSession.close()
@@ -827,11 +827,16 @@ describe('#integration examples', () => {
827827
// end::rx-transaction-function[]
828828

829829
const people = await result.toPromise()
830-
expect(people).toEqual([
831-
Notification.createNext('Infinity Gauntlet'),
832-
Notification.createNext('Mjölnir'),
830+
expect(people.length).toEqual(3)
831+
expect(people).toContain(
832+
Notification.createNext('Infinity Gauntlet')
833+
)
834+
expect(people).toContain(
835+
Notification.createNext('Mjölnir')
836+
)
837+
expect(people).toContain(
833838
Notification.createComplete()
834-
])
839+
)
835840
}, 60000)
836841

837842
it('configure transaction timeout', async () => {

packages/neo4j-driver/test/internal/connection-channel.test.js

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ const SUCCESS_MESSAGE = { signature: 0x70, fields: [{}] }
4747
const FAILURE_MESSAGE = { signature: 0x7f, fields: [newError('Hello')] }
4848
const RECORD_MESSAGE = { signature: 0x71, fields: [{ value: 'Hello' }] }
4949

50+
const BOLT_AGENT = {
51+
product: 'js-driver',
52+
platform: 'SomePlatform',
53+
language: 'js',
54+
languageDetails: 'Some node or deno details'
55+
}
56+
5057
describe('#integration ChannelConnection', () => {
5158
/** @type {Connection} */
5259
let connection
@@ -77,6 +84,7 @@ describe('#integration ChannelConnection', () => {
7784
.then(connection => {
7885
connection.protocol().initialize({
7986
userAgent: 'mydriver/0.0.0',
87+
boltAgent: BOLT_AGENT,
8088
authToken: basicAuthToken(),
8189
onComplete: metadata => {
8290
expect(metadata).not.toBeNull()
@@ -104,7 +112,7 @@ describe('#integration ChannelConnection', () => {
104112
}
105113

106114
connection
107-
.connect('mydriver/0.0.0', 'mydriver/0.0.0 some system info', basicAuthToken())
115+
.connect('mydriver/0.0.0', BOLT_AGENT, basicAuthToken())
108116
.then(() => {
109117
connection
110118
.protocol()
@@ -177,7 +185,7 @@ describe('#integration ChannelConnection', () => {
177185
connection = await createConnection(`bolt://${sharedNeo4j.hostname}`)
178186

179187
connection
180-
.connect('mydriver/0.0.0', 'mydriver/0.0.0 some system info', basicAuthToken())
188+
.connect('mydriver/0.0.0', BOLT_AGENT, basicAuthToken())
181189
.then(initializedConnection => {
182190
expect(initializedConnection).toBe(connection)
183191
done()
@@ -189,7 +197,7 @@ describe('#integration ChannelConnection', () => {
189197
connection = await createConnection(`bolt://${sharedNeo4j.hostname}`) // wrong port
190198

191199
connection
192-
.connect('mydriver/0.0.0', 'mydriver/0.0.0 some system info', basicWrongAuthToken())
200+
.connect('mydriver/0.0.0', BOLT_AGENT, basicWrongAuthToken())
193201
.then(() => done.fail('Should not initialize'))
194202
.catch(error => {
195203
expect(error).toBeDefined()
@@ -200,7 +208,7 @@ describe('#integration ChannelConnection', () => {
200208
it('should have server version after connection initialization completed', async done => {
201209
connection = await createConnection(`bolt://${sharedNeo4j.hostname}`)
202210
connection
203-
.connect('mydriver/0.0.0', 'mydriver/0.0.0 some system info', basicAuthToken())
211+
.connect('mydriver/0.0.0', BOLT_AGENT, basicAuthToken())
204212
.then(initializedConnection => {
205213
expect(initializedConnection).toBe(connection)
206214
const serverVersion = ServerVersion.fromString(connection.version)
@@ -214,7 +222,7 @@ describe('#integration ChannelConnection', () => {
214222
connection = await createConnection(`bolt://${sharedNeo4j.hostname}`)
215223

216224
connection
217-
.connect('mydriver/0.0.0', 'mydriver/0.0.0 some system info', basicWrongAuthToken())
225+
.connect('mydriver/0.0.0', BOLT_AGENT, basicWrongAuthToken())
218226
.then(() => done.fail('Should not connect'))
219227
.catch(initialError => {
220228
expect(initialError).toBeDefined()
@@ -244,7 +252,7 @@ describe('#integration ChannelConnection', () => {
244252
it('should not queue INIT observer when broken', done => {
245253
testQueueingOfObserversWithBrokenConnection(
246254
connection =>
247-
connection.protocol().initialize({ userAgent: 'Hello', authToken: {} }),
255+
connection.protocol().initialize({ userAgent: 'Hello', boltAgent: BOLT_AGENT, authToken: {} }),
248256
done
249257
)
250258
})
@@ -274,7 +282,7 @@ describe('#integration ChannelConnection', () => {
274282
connection = await createConnection(`bolt://${sharedNeo4j.hostname}`)
275283

276284
connection
277-
.connect('my-driver/1.2.3', 'mydriver/0.0.0 some system info', basicAuthToken())
285+
.connect('my-driver/1.2.3', BOLT_AGENT, basicAuthToken())
278286
.then(() => {
279287
connection
280288
.resetAndFlush()
@@ -297,7 +305,7 @@ describe('#integration ChannelConnection', () => {
297305
it('should fail to reset and flush when FAILURE received', async done => {
298306
createConnection(`bolt://${sharedNeo4j.hostname}`)
299307
.then(connection => {
300-
connection.connect('my-driver/1.2.3', 'mydriver/0.0.0 some system info', basicAuthToken()).then(() => {
308+
connection.connect('my-driver/1.2.3', BOLT_AGENT, basicAuthToken()).then(() => {
301309
connection
302310
.resetAndFlush()
303311
.then(() => done.fail('Should fail'))
@@ -325,7 +333,7 @@ describe('#integration ChannelConnection', () => {
325333
connection = await createConnection(`bolt://${sharedNeo4j.hostname}`)
326334

327335
connection
328-
.connect('my-driver/1.2.3', 'mydriver/0.0.0 some system info', basicAuthToken())
336+
.connect('my-driver/1.2.3', BOLT_AGENT, basicAuthToken())
329337
.then(() => {
330338
connection
331339
.resetAndFlush()
@@ -353,7 +361,7 @@ describe('#integration ChannelConnection', () => {
353361
createConnection(`bolt://${sharedNeo4j.hostname}`)
354362
.then(connection => {
355363
connection
356-
.connect('my-driver/1.2.3', 'mydriver/0.0.0 some system info', basicAuthToken())
364+
.connect('my-driver/1.2.3', BOLT_AGENT, basicAuthToken())
357365
.then(() => {
358366
connection.protocol()._responseHandler._currentFailure = newError(
359367
'Hello'
@@ -419,7 +427,7 @@ describe('#integration ChannelConnection', () => {
419427
connection = await createConnection(`bolt://${sharedNeo4j.hostname}`)
420428
recordWrittenMessages(connection._protocol, messages)
421429

422-
await connection.connect('mydriver/0.0.0', 'mydriver/0.0.0 some system info', basicAuthToken())
430+
await connection.connect('mydriver/0.0.0', BOLT_AGENT, basicAuthToken())
423431

424432
expect(connection.isOpen()).toBeTruthy()
425433
await connection.close()
@@ -436,7 +444,7 @@ describe('#integration ChannelConnection', () => {
436444
it('should not prepare broken connection to close', async () => {
437445
connection = await createConnection(`bolt://${sharedNeo4j.hostname}`)
438446

439-
await connection.connect('my-connection/9.9.9', 'mydriver/0.0.0 some system info', basicAuthToken())
447+
await connection.connect('my-connection/9.9.9', BOLT_AGENT, basicAuthToken())
440448
expect(connection._protocol).toBeDefined()
441449
expect(connection._protocol).not.toBeNull()
442450

0 commit comments

Comments
 (0)