Skip to content

Commit

Permalink
test: add conformance tests for declarative functions signatures (#353)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewrobertson committed Oct 9, 2021
1 parent db1ba9e commit 01c7b9d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
26 changes: 22 additions & 4 deletions .github/workflows/conformance.yml
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-18.04
strategy:
matrix:
runtime: ['nodejs10', 'nodejs12']
runtime: ['nodejs10', 'nodejs12', 'nodejs14', 'nodejs16']
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -31,7 +31,7 @@ jobs:
working-directory: ./test/conformance
run: npm install

- name: Run HTTP conformance tests
- name: Run HTTP conformance tests using legacy API
uses: GoogleCloudPlatform/functions-framework-conformance/action@v1.0.0
with:
functionType: 'http'
Expand All @@ -40,7 +40,7 @@ jobs:
workingDirectory: 'test/conformance'
cmd: "'npm start -- --target=writeHttp --signature-type=http'"

- name: Run event conformance tests
- name: Run event conformance tests using legacy API
uses: GoogleCloudPlatform/functions-framework-conformance/action@v1.0.0
with:
functionType: 'legacyevent'
Expand All @@ -49,11 +49,29 @@ jobs:
workingDirectory: 'test/conformance'
cmd: "'npm start -- --target=writeLegacyEvent --signature-type=event'"

- name: Run cloudevent conformance tests
- name: Run cloudevent conformance tests using legacy API
uses: GoogleCloudPlatform/functions-framework-conformance/action@v1.0.0
with:
functionType: 'cloudevent'
useBuildpacks: false
validateMapping: true
workingDirectory: 'test/conformance'
cmd: "'npm start -- --target=writeCloudEvent --signature-type=cloudevent'"

- name: Run HTTP conformance tests using declarative API
uses: GoogleCloudPlatform/functions-framework-conformance/action@v1.0.0
with:
functionType: 'http'
useBuildpacks: false
validateMapping: false
workingDirectory: 'test/conformance'
cmd: "'npm start -- --target=writeHttpDeclarative'"

- name: Run cloudevent conformance tests using declarative API
uses: GoogleCloudPlatform/functions-framework-conformance/action@v1.0.0
with:
functionType: 'cloudevent'
useBuildpacks: false
validateMapping: true
workingDirectory: 'test/conformance'
cmd: "'npm start -- --target=writeCloudEventDeclarative'"
12 changes: 12 additions & 0 deletions test/conformance/function.js
@@ -1,6 +1,18 @@
/* eslint-disable node/no-missing-require */
const fs = require('fs');
const functions = require('@google-cloud/functions-framework');
const fileName = 'function_output.json';

functions.http('writeHttpDeclarative', (req, res) => {
writeJson(req.body);
res.end(200);
});

functions.cloudevent('writeCloudEventDeclarative', cloudevent => {
cloudevent.datacontenttype = 'application/json';
writeJson(cloudevent);
});

function writeHttp(req, res) {
writeJson(req.body);
res.end(200);
Expand Down

0 comments on commit 01c7b9d

Please sign in to comment.