Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions functions/helloworld_pubsub/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ function helloworldPubsub(CloudEvent $event): void
$log = fopen(getenv('LOGGER_OUTPUT') ?: 'php://stderr', 'wb');

$cloudEventData = $event->getData();
if (isset($cloudEventData['data'])) {
$name = htmlspecialchars(base64_decode($cloudEventData['data']));
$pubSubData = base64_decode($cloudEventData['message']['data']);

if ($pubSubData) {
$name = htmlspecialchars($pubSubData);
} else {
$name = 'World';
}
Expand Down
4 changes: 0 additions & 4 deletions functions/helloworld_pubsub/test/DeployTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ public function testHelloworldPubsub(string $name, string $expected, string $lab
// Send Pub/Sub message.
$this->publishMessage($name);

// Give event and log systems a head start.
// If log retrieval fails to find logs for our function within retry limit, increase sleep time.
sleep(60);

$fiveMinAgo = date(\DateTime::RFC3339, strtotime('-5 minutes'));
$this->processFunctionLogs($fiveMinAgo, function (\Iterator $logs) use ($name, $expected, $label) {
// Concatenate all relevant log messages.
Expand Down
4 changes: 3 additions & 1 deletion functions/helloworld_pubsub/test/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ public function dataProvider()
'type' => 'google.cloud.pubsub.topic.v1.messagePublished',
],
'data' => [
'data' => base64_encode('John')
'message' => [
'data' => base64_encode('John')
]
],
'statusCode' => 200,
'expected' => 'Hello, John!',
Expand Down