Skip to content

Commit 3cb262e

Browse files
authored
Make Python PubSub sample match other language ones (GoogleCloudPlatform#7470)
* Should output "Hello, {pubsub message}!" * Remove output wrappers (Hello, and !) from message * Decode to str * Update main.py * Update main.py
1 parent 9f365f8 commit 3cb262e

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

functions/v2/pubsub/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@
2222
@functions_framework.cloud_event
2323
def subscribe(cloud_event):
2424
# Print out the data from Pub/Sub, to prove that it worked
25-
print(base64.b64decode(cloud_event.data["message"]["data"]))
25+
print("Hello, " + base64.b64decode(cloud_event.data["message"]["data"]).decode() + "!")
2626
# [END functions_cloudevent_pubsub]

functions/v2/pubsub/main_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def test_functions_pubsub_subscribe_should_print_message(capsys):
2222

2323
event.data = {
2424
"message": {
25-
"data": base64.b64encode(b"Hello, world!"),
25+
"data": base64.b64encode(b"world"),
2626
}
2727
}
2828

0 commit comments

Comments
 (0)