Skip to content

Commit

Permalink
Fix: PromisePoolCluster.of returns PromisePoolCluster instead of Pool…
Browse files Browse the repository at this point in the history
…Namespace (sidorares#3091)
  • Loading branch information
jcmartineztiempo committed Dec 6, 2024
1 parent d39eb82 commit 8f27b41
Showing 1 changed file with 8 additions and 38 deletions.
46 changes: 8 additions & 38 deletions test/esm/integration/pool-cluster/test-promise-wrapper.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -80,42 +80,6 @@ const { createPoolCluster } = require('../../../../promise.js');
poolCluster.poolCluster.emit('online');
});

await test(async () => {
const poolCluster = createPoolCluster();

poolCluster.once('offline', async function () {
await new Promise((resolve) => {
assert.equal(
// eslint-disable-next-line no-invalid-this
this,
poolCluster,
'should propagate offline event to promise wrapper',
);
resolve(true);
});
});

poolCluster.poolCluster.emit('offline');
});

await test(async () => {
const poolCluster = createPoolCluster();

poolCluster.once('online', async function () {
await new Promise((resolve) => {
assert.equal(
// eslint-disable-next-line no-invalid-this
this,
poolCluster,
'should propagate online event to promise wrapper',
);
resolve(true);
});
});

poolCluster.poolCluster.emit('online');
});

await test(async () => {
const poolCluster = createPoolCluster();
poolCluster.add('MASTER', common.config);
Expand All @@ -127,10 +91,16 @@ const { createPoolCluster } = require('../../../../promise.js');
assert.ok(connection, 'should get connection');
connection.release();

const result = await poolNamespace.query('SELECT 1 as a from dual where 1 = ?', [1]);
const result = await poolNamespace.query(
'SELECT 1 as a from dual where 1 = ?',
[1],
);
assert.equal(result[0]['a'], 1, 'should query successfully');

const result2 = await poolNamespace.execute('SELECT 1 as a from dual where 1 = ?', [1]);
const result2 = await poolNamespace.execute(
'SELECT 1 as a from dual where 1 = ?',
[1],
);
assert.equal(result2[0]['a'], 1, 'should execute successfully');
});
})();

0 comments on commit 8f27b41

Please sign in to comment.