Skip to content

Commit

Permalink
test: fix unit test IP parsing error in Node.js 18.x (#5247)
Browse files Browse the repository at this point in the history
Since Nodejs v18.16.x has upgraded the version of Ada, now if we use
something like "numeric IP address", it cannot be parsed successfully.
We should use Latin-like chars instead.
  • Loading branch information
Wai-Dung committed Aug 5, 2023
1 parent 2aefdc7 commit 3d5f1dc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
7 changes: 1 addition & 6 deletions test/fixtures/apps/cluster_mod_app/lib/registry_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,16 @@ class RegistryClient extends Base {
*/
publish(reg) {
const key = reg.dataId;
let changed = false;

if (this._registered.has(key)) {
const arr = this._registered.get(key);
if (arr.indexOf(reg.publishData) === -1) {
changed = true;
arr.push(reg.publishData);
}
} else {
changed = true;
this._registered.set(key, [reg.publishData]);
}
if (changed) {
this.emit(key, this._registered.get(key).map(url => URL.parse(url, true)));
}
this.emit(key, this._registered.get(key).map(url => new URL.parse(url, true)));
}

close() {
Expand Down
12 changes: 6 additions & 6 deletions test/lib/cluster/cluster-client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ describe('test/lib/cluster/cluster-client.test.js', () => {
mm.restore();
});

it('should publish & subscribe ok', () => {
it('should publish & subscribe', () => {
return app.httpRequest()
.post('/publish')
.send({ value: '30.20.78.299' })
.send({ value: 'www.testme.com' })
.expect('ok')
.expect(200)
.then(() => {
Expand All @@ -34,7 +34,7 @@ describe('test/lib/cluster/cluster-client.test.js', () => {
.then(() => {
return app.httpRequest()
.get('/getHosts')
.expect('30.20.78.299:20880')
.expect('www.testme.com:20880')
.expect(200);
});
});
Expand Down Expand Up @@ -70,10 +70,10 @@ describe('test/lib/cluster/cluster-client.test.js', () => {
mm.restore();
});

it('should publish & subscribe ok', () => {
it('should publish & subscribe', () => {
return app.httpRequest()
.post('/publish')
.send({ value: '30.20.78.299' })
.send({ value: 'www.testme.com' })
.expect('ok')
.expect(200)
.then(() => {
Expand All @@ -84,7 +84,7 @@ describe('test/lib/cluster/cluster-client.test.js', () => {
.then(() => {
return app.httpRequest()
.get('/getHosts')
.expect('30.20.78.299:20880')
.expect('www.testme.com:20880')
.expect(200);
});
});
Expand Down

0 comments on commit 3d5f1dc

Please sign in to comment.