From bd1b548cd8b8a69b209a854f3f25fc4d13a26ee7 Mon Sep 17 00:00:00 2001 From: Khushboo Verma Date: Mon, 28 Jul 2025 10:44:40 +0530 Subject: [PATCH] Add logs to event-handler function --- .../Functions/FunctionsCustomServerTest.php | 3 +++ .../resources/functions/event-handler/index.js | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 3acbcae0ee..eec0d6a236 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -1515,6 +1515,9 @@ class FunctionsCustomServerTest extends Scope $this->assertArrayHasKey('x-appwrite-execution-delay', $requestHeaders); $this->assertIsNumeric($requestHeaders['x-appwrite-execution-delay']); $this->assertGreaterThan($requestHeaders['x-appwrite-scheduled-at'], $requestHeaders['x-appwrite-executed-at']); + $this->assertStringContainsString('execution-delay-is-valid', $lastExecution['logs']); + $this->assertStringContainsString('scheduled-at-is-valid', $lastExecution['logs']); + $this->assertStringContainsString('executed-at-is-valid', $lastExecution['logs']); }, 10000, 500); diff --git a/tests/resources/functions/event-handler/index.js b/tests/resources/functions/event-handler/index.js index 6df3b7fb35..3ffcc7a1d5 100644 --- a/tests/resources/functions/event-handler/index.js +++ b/tests/resources/functions/event-handler/index.js @@ -1,5 +1,22 @@ module.exports = async(context) => { context.log(context.req.body.$id); context.log(context.req.body.name); + if (context.req.headers["x-appwrite-execution-delay"]) { + context.log("execution-delay-is-valid"); + } else { + context.log("execution-delay-is-invalid"); + } + + if (context.req.headers["x-appwrite-scheduled-at"]) { + context.log("scheduled-at-is-valid"); + } else { + context.log("scheduled-at-is-invalid"); + } + + if (context.req.headers["x-appwrite-executed-at"]) { + context.log("executed-at-is-valid"); + } else { + context.log("executed-at-is-invalid"); + } return context.res.empty(); };