MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / startFF

Function startFF

functions/imagemagick/test/index.test.js:35–63  ·  view source on GitHub ↗
(port)

Source from the content-addressed store, hash-verified

33};
34
35async function startFF(port) {
36 const ffProc = spawn('npx', [
37 'functions-framework',
38 '--target',
39 'blurOffensiveImages',
40 '--signature-type',
41 'event',
42 '--port',
43 port,
44 ]);
45 const ffProcHandler = new Promise((resolve, reject) => {
46 let stdout = '';
47 let stderr = '';
48 ffProc.stdout.on('data', data => (stdout += data));
49 ffProc.stderr.on('data', data => (stderr += data));
50 ffProc.on('exit', code => {
51 if (code === 0 || code === null) {
52 // code === null corresponds to a signal-kill
53 // (which doesn't necessarily indicate a test failure)
54 resolve(stdout);
55 } else {
56 stderr = `Error code: ${code}\n${stderr}`;
57 reject(new Error(stderr));
58 }
59 });
60 });
61 await waitPort({host: 'localhost', port});
62 return {ffProc, ffProcHandler};
63}
64
65describe('functions/imagemagick tests', () => {
66 before(async () => {

Callers 1

index.test.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected