Update functions vars -> variables

This commit is contained in:
Jake Barnby committed 2022-09-22 14:16:13 +12:00
1 parent 734561c6b6
commit f2af301f16
3 files changed
+118 -22

No files matched your search

@@ -25,12 +25,8 @@ class GraphQLFunctionsClientTest extends Scope
'variables' => [
'functionId' => ID::unique(),
'name' => 'Test Function',
'runtime' => 'ruby-3.0',
'vars' => [
'name' => 'John Doe',
'age' => 42,
]
'execute' => [Role::any()],
'runtime' => 'php-8.0',
'execute' => [Role::any()->toString()],
]
];
@@ -40,10 +36,40 @@ class GraphQLFunctionsClientTest extends Scope
'x-appwrite-key' => $this->getProject()['apiKey'],
], $gqlPayload);
$this->assertIsArray($function['body']['data']);
$this->assertArrayNotHasKey('errors', $function['body']);
return $function['body']['data']['functionsCreate'];
$function = $function['body']['data']['functionsCreate'];
$functionId = $function['_id'];
$query = '
mutation createVariables($functionId: String!) {
var1: functionsCreateVariable(functionId: $functionId, key: "name", value: "John Doe") {
_id
}
var2: functionsCreateVariable(functionId: $functionId, key: "age", value: "42") {
_id
}
}
';
$gqlPayload = [
'query' => $query,
'variables' => [
'functionId' => $functionId,
]
];
$variables = $this->client->call(Client::METHOD_POST, '/graphql', [
'content-type' => 'application/json',
'x-appwrite-project' => $projectId,
'x-appwrite-key' => $this->getProject()['apiKey'],
], $gqlPayload);
$this->assertIsArray($variables['body']['data']);
$this->assertArrayNotHasKey('errors', $variables['body']);
return $function;
}
/**
@@ -56,13 +82,13 @@ class GraphQLFunctionsClientTest extends Scope
{
$projectId = $this->getProject()['$id'];
$query = $this->getQuery(self::$CREATE_DEPLOYMENT);
$code = realpath(__DIR__ . '/../../../resources/functions') . "/ruby/code.tar.gz";
$code = realpath(__DIR__ . '/../../../resources/functions') . "/php/code.tar.gz";
$gqlPayload = [
'operations' => \json_encode([
'query' => $query,
'variables' => [
'functionId' => $function['_id'],
'entrypoint' => 'main.rb',
'entrypoint' => 'index.php',
'activate' => true,
'code' => null,
]