From 33fb2e3edd7b1cb801e70b4ffbe96c83cb0a2af4 Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Wed, 10 Mar 2021 13:05:43 -0500 Subject: [PATCH] Test for custom data in execution --- .../Functions/FunctionsCustomServerTest.php | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 9dded8fdd7..943e43cfbc 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -343,6 +343,37 @@ class FunctionsCustomServerTest extends Scope /** * @depends testCreateExecution */ + public function testCreateCustomExecution($data):array + { + /** + * Test for SUCCESS + */ + $execution = $this->client->call(Client::METHOD_POST, '/functions/'.$data['functionId'].'/executions', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'data' => 'foobar', + ]); + + print_r($execution); + $executionId = $execution['body']['$id'] ?? ''; + + $this->assertEquals(201, $execution['headers']['status-code']); + $this->assertNotEmpty($execution['body']['$id']); + $this->assertNotEmpty($execution['body']['functionId']); + $this->assertIsInt($execution['body']['dateCreated']); + $this->assertEquals($data['functionId'], $execution['body']['functionId']); + $this->assertEquals('waiting', $execution['body']['status']); + $this->assertEquals(0, $execution['body']['exitCode']); + $this->assertEquals('', $execution['body']['stdout']); + $this->assertEquals('', $execution['body']['stderr']); + $this->assertEquals(0, $execution['body']['time']); + $this->assertStringContainsString('foobar', $execution['body']['stdout']); + + } + /** + * @depends testCreateCustomExecution + */ public function testListExecutions(array $data):array { /**