1
0
Fork 0
mirror of synced 2024-06-26 10:10:57 +12:00

test(functions): adds dart test

This commit is contained in:
Torsten Dittmann 2021-01-21 10:38:24 +01:00
parent e64f0f3c5e
commit d8ec0c59e3
4 changed files with 53 additions and 0 deletions

View file

@ -535,6 +535,14 @@ class FunctionsCustomServerTest extends Scope
'command' => 'deno run --allow-env index.ts',
'timeout' => 15,
],
[
'language' => 'Dart',
'version' => '2.10.4',
'name' => 'dart-2.10.4',
'code' => $functions.'/dart.tar.gz',
'command' => 'dart run main.dart',
'timeout' => 15,
],
];
sleep(count($envs) * 25);

View file

@ -0,0 +1,26 @@
import 'dart:io';
import 'package:dart_appwrite/dart_appwrite.dart';
void main() { // Init SDK
Client client = Client();
client
.setEndpoint(process.env.APPWRITE_ENDPOINT) // Your API Endpoint
.setProject(process.env.APPWRITE_PROJECT) // Your project ID
.setKey(process.env.APPWRITE_SECRET) // Your secret API key
;
Storage storage = Storage(client);
//Future result = storage.getFile(fileId: '[FILE_ID]');
print(process.env.APPWRITE_FUNCTION_ID);
print(process.env.APPWRITE_FUNCTION_NAME);
print(process.env.APPWRITE_FUNCTION_TAG);
print(process.env.APPWRITE_FUNCTION_TRIGGER);
print(process.env.APPWRITE_FUNCTION_ENV_NAME);
print(process.env.APPWRITE_FUNCTION_ENV_VERSION);
// print(result['$id']);
print(process.env.APPWRITE_FUNCTION_EVENT);
print(process.env.APPWRITE_FUNCTION_EVENT_PAYLOAD);
}

View file

@ -0,0 +1,7 @@
name: appwrite_cloud_function_demo
version: 0.1.0
description: Demo cloud function script.
environment:
sdk: '>=2.10.0 <3.0.0'
dependencies:
dart_appwrite: ^0.1.0

View file

@ -0,0 +1,12 @@
echo 'Dart Packaging...'
cp -r $(pwd)/tests/resources/functions/dart $(pwd)/tests/resources/functions/packages/dart
docker run --rm -v $(pwd)/tests/resources/functions/packages/dart:/app -w /app appwrite/env-deno-dart-2.10.4:1.0.0 dart pub get
docker run --rm -v $(pwd)/tests/resources/functions/packages/dart:/app -w /app appwrite/env-deno-dart-2.10.4:1.0.0 tar -zcvf code.tar.gz .
mv $(pwd)/tests/resources/functions/packages/dart/code.tar.gz $(pwd)/tests/resources/functions/dart.tar.gz
rm -r $(pwd)/tests/resources/functions/packages/dart