Skip to content

Commit 01c7b9d

Browse files
test: add conformance tests for declarative functions signatures (#353)
1 parent db1ba9e commit 01c7b9d

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

.github/workflows/conformance.yml

+22-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-18.04
1010
strategy:
1111
matrix:
12-
runtime: ['nodejs10', 'nodejs12']
12+
runtime: ['nodejs10', 'nodejs12', 'nodejs14', 'nodejs16']
1313
steps:
1414
- name: Checkout code
1515
uses: actions/checkout@v2
@@ -31,7 +31,7 @@ jobs:
3131
working-directory: ./test/conformance
3232
run: npm install
3333

34-
- name: Run HTTP conformance tests
34+
- name: Run HTTP conformance tests using legacy API
3535
uses: GoogleCloudPlatform/functions-framework-conformance/[email protected]
3636
with:
3737
functionType: 'http'
@@ -40,7 +40,7 @@ jobs:
4040
workingDirectory: 'test/conformance'
4141
cmd: "'npm start -- --target=writeHttp --signature-type=http'"
4242

43-
- name: Run event conformance tests
43+
- name: Run event conformance tests using legacy API
4444
uses: GoogleCloudPlatform/functions-framework-conformance/[email protected]
4545
with:
4646
functionType: 'legacyevent'
@@ -49,11 +49,29 @@ jobs:
4949
workingDirectory: 'test/conformance'
5050
cmd: "'npm start -- --target=writeLegacyEvent --signature-type=event'"
5151

52-
- name: Run cloudevent conformance tests
52+
- name: Run cloudevent conformance tests using legacy API
5353
uses: GoogleCloudPlatform/functions-framework-conformance/[email protected]
5454
with:
5555
functionType: 'cloudevent'
5656
useBuildpacks: false
5757
validateMapping: true
5858
workingDirectory: 'test/conformance'
5959
cmd: "'npm start -- --target=writeCloudEvent --signature-type=cloudevent'"
60+
61+
- name: Run HTTP conformance tests using declarative API
62+
uses: GoogleCloudPlatform/functions-framework-conformance/[email protected]
63+
with:
64+
functionType: 'http'
65+
useBuildpacks: false
66+
validateMapping: false
67+
workingDirectory: 'test/conformance'
68+
cmd: "'npm start -- --target=writeHttpDeclarative'"
69+
70+
- name: Run cloudevent conformance tests using declarative API
71+
uses: GoogleCloudPlatform/functions-framework-conformance/[email protected]
72+
with:
73+
functionType: 'cloudevent'
74+
useBuildpacks: false
75+
validateMapping: true
76+
workingDirectory: 'test/conformance'
77+
cmd: "'npm start -- --target=writeCloudEventDeclarative'"

test/conformance/function.js

+12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
1+
/* eslint-disable node/no-missing-require */
12
const fs = require('fs');
3+
const functions = require('@google-cloud/functions-framework');
24
const fileName = 'function_output.json';
35

6+
functions.http('writeHttpDeclarative', (req, res) => {
7+
writeJson(req.body);
8+
res.end(200);
9+
});
10+
11+
functions.cloudevent('writeCloudEventDeclarative', cloudevent => {
12+
cloudevent.datacontenttype = 'application/json';
13+
writeJson(cloudevent);
14+
});
15+
416
function writeHttp(req, res) {
517
writeJson(req.body);
618
res.end(200);

0 commit comments

Comments
 (0)