Skip to content

Commit cf7b076

Browse files
committed
[misc] improve named pipe test reliability with better error handling and skip conditions
1 parent 530f16c commit cf7b076

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

test/integration/socket.test.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,16 @@ describe.concurrent('test socket', () => {
2323
if (Conf.baseConfig.host !== 'localhost' && Conf.baseConfig.host !== 'mariadb.example.com') return skip();
2424

2525
const res = await shareConn.query('select @@version_compile_os,@@socket soc, @@named_pipe pipeEnable');
26-
if (res[0].pipeEnable === 0) {
26+
if (!res[0].pipeEnable || Number(res[0].pipeEnable) === 0) {
2727
return skip();
2828
}
29-
const conn = await createConnection({ socketPath: '\\\\.\\pipe\\' + res[0].soc });
29+
let conn;
30+
try {
31+
conn = await createConnection({ socketPath: '\\\\.\\pipe\\' + res[0].soc });
32+
} catch (err) {
33+
if (err.code === 'ENOENT') return skip();
34+
throw err;
35+
}
3036
await conn.connect();
3137
await conn.query('DO 1');
3238
await conn.end();

0 commit comments

Comments
 (0)