8000 chore: Add conformance tests for declarative functions (#165) · jinjunnn/google-functions-python@85b7e43 · GitHub
[go: up one dir, main page]

Skip to content

Commit 85b7e43

Browse files
authored
chore: Add conformance tests for declarative functions (GoogleCloudPlatform#165)
1 parent 75cc22c commit 85b7e43

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

.github/workflows/conformance.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,21 @@ jobs:
4949
useBuildpacks: false
5050
validateMapping: true
5151
cmd: "'functions-framework --source tests/conformance/main.py --target write_cloud_event --signature-type cloudevent'"
52+
53+
- name: Run HTTP conformance tests declarative
54+
uses: GoogleCloudPlatform/functions-framework-conformance/action@v1.1.0
55+
with:
56+
version: 'v1.1.0'
57+
functionType: 'http'
58+
useBuildpacks: false
59+
validateMapping: false
60+
cmd: "'functions-framework --source tests/conformance/main.py --target write_http_declarative'"
61+
62+
- name: Run cloudevent conformance tests declarative
63+
uses: GoogleCloudPlatform/functions-framework-conformance/action@v1.1.0
64+
with:
65+
version: 'v1.1.0'
66+
functionType: 'cloudevent'
67+
useBuildpacks: false
68+
validateMapping: true
69+
cmd: "'functions-framework --source tests/conformance/main.py --target write_cloudevent_declarative'"

tests/conformance/main.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from cloudevents.http import to_json
44

5+
import functions_framework
6+
57
filename = "function_output.json"
68

79

@@ -33,3 +35,14 @@ def write_legacy_event(data, context):
3335

3436
def write_cloud_event(cloudevent):
3537
_write_output(to_json(cloudevent).decode())
38+
39+
40+
@functions_framework.http
41+
def write_http_declarative(request):
42+
_write_output(json.dumps(request.json))
43+
return "OK", 200
44+
45+
46+
@functions_framework.cloudevent
47+
def write_cloudevent_declarative(cloudevent):
48+
_write_output(to_json(cloudevent).decode())

0 commit comments

Comments
 (0)
0