Skip to content

Commit 449ddcd

Browse files
author
Ace Nassri
committed
Re-enable tests + switch to wait-port
1 parent eaff4be commit 449ddcd

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

datastore/functions/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
"test": "mocha test/*.test.js --timeout=5000"
1515
},
1616
"dependencies": {
17-
"@google-cloud/datastore": "^7.0.0",
18-
"is-reachable": "^5.0.0"
17+
"@google-cloud/datastore": "^7.0.0"
1918
},
2019
"devDependencies": {
2120
"@google-cloud/functions-framework": "^3.0.0",
@@ -24,6 +23,7 @@
2423
"node-fetch": "^2.6.1",
2524
"proxyquire": "^2.1.0",
2625
"sinon": "^15.0.0",
27-
"uuid": "^8.0.0"
26+
"uuid": "^8.0.0",
27+
"wait-port": "^1.0.4"
2828
}
2929
}

datastore/functions/test/index.test.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const path = require('path');
2020
const uuid = require('uuid');
2121
const sinon = require('sinon');
2222
const fetch = require('node-fetch');
23-
const isReachable = require('is-reachable');
23+
const waitPort = require('wait-port');
2424
const {Datastore} = require('@google-cloud/datastore');
2525

2626
const datastore = new Datastore();
@@ -49,16 +49,7 @@ const handleLinuxFailures = async proc => {
4949
}
5050
};
5151

52-
// Wait for the HTTP server to start listening
53-
const waitForReady = async baseUrl => {
54-
let ready = false;
55-
while (!ready) {
56-
await new Promise(r => setTimeout(r, 500));
57-
ready = await isReachable(baseUrl);
58-
}
59-
};
60-
61-
describe.skip('functions/datastore', () => {
52+
describe('functions/datastore', () => {
6253
describe('set', () => {
6354
let ffProc;
6455
const PORT = 8080;
@@ -69,7 +60,7 @@ describe.skip('functions/datastore', () => {
6960
`functions-framework --target=set --signature-type=http --port=${PORT}`,
7061
{timeout: FF_TIMEOUT, shell: true, cwd}
7162
);
72-
await waitForReady(BASE_URL);
63+
await waitPort({port: PORT});
7364
});
7465

7566
after(async () => {
@@ -150,7 +141,7 @@ describe.skip('functions/datastore', () => {
150141
`functions-framework --target=get --signature-type=http --port=${PORT}`,
151142
{timeout: FF_TIMEOUT, shell: true, cwd}
152143
);
153-
await waitForReady(BASE_URL);
144+
await waitPort({port: PORT});
154145
});
155146

156147
after(async () => {
@@ -236,7 +227,7 @@ describe.skip('functions/datastore', () => {
236227
`functions-framework --target=del --signature-type=http --port=${PORT}`,
237228
{timeout: FF_TIMEOUT, shell: true, cwd}
238229
);
239-
await waitForReady(BASE_URL);
230+
await waitPort({port: PORT});
240231
});
241232

242233
after(async () => {

0 commit comments

Comments
 (0)