Skip to content

Commit ccc6747

Browse files
authored
chore: Add conformance test for typed decorator (#212)
1 parent aa59a6b commit ccc6747

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

.github/workflows/conformance.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,12 @@ jobs:
7676
useBuildpacks: false
7777
validateConcurrency: true
7878
cmd: "'functions-framework --source tests/conformance/main.py --target write_http_declarative_concurrent'"
79+
80+
- name: Run Typed tests declarative
81+
uses: GoogleCloudPlatform/functions-framework-conformance/[email protected]
82+
with:
83+
version: 'v1.6.0'
84+
functionType: 'http'
85+
useBuildpacks: false
86+
validateMapping: false
87+
cmd: "'functions-framework --source tests/conformance/main.py --target write_typed_event_declarative'"

tests/conformance/main.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@
88
filename = "function_output.json"
99

1010

11+
class ConformanceType:
12+
json_request: str
13+
14+
def __init__(self, json_request: str) -> None:
15+
self.json_request = json_request
16+
17+
@staticmethod
18+
def from_dict(obj: dict) -> "ConformanceType":
19+
return ConformanceType(json.dumps(obj))
20+
21+
1122
def _write_output(content):
1223
with open(filename, "w") as f:
1324
f.write(content)
@@ -53,3 +64,9 @@ def write_cloud_event_declarative(cloud_event):
5364
def write_http_declarative_concurrent(request):
5465
time.sleep(1)
5566
return "OK", 200
67+
68+
69+
@functions_framework.typed(ConformanceType)
70+
def write_typed_event_declarative(x):
71+
_write_output(x.json_request)
72+
return "OK"

0 commit comments

Comments
 (0)