-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathruntime_test.dart
45 lines (33 loc) · 1.37 KB
/
runtime_test.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import "package:test/test.dart";
import 'package:aws_lambda_dart_runtime/aws_lambda_dart_runtime.dart';
void main() {
group('runtime', () {
test("instance is created without error", () {
expect(() => Runtime(), returnsNormally);
});
test("instance is same accross invocation", () async {
final runtime = await Runtime();
expect(runtime, await Runtime());
});
test("successfully add a handler to runtime", () async {
final runtime = await Runtime();
final Handler<AwsS3Event> testHandler = (context, event) async {
return new InvocationResult(context.requestId, "HELLO WORLD");
};
final addHandler = runtime.registerHandler("test.handler", testHandler);
expect(runtime.handlerExists("test.handler"), equals(true));
expect(addHandler, equals(testHandler));
});
test("successfully deregister a handler to runtime", () async {
final runtime = await Runtime();
final Handler<AwsS3Event> testHandler = (context, event) async {
return new InvocationResult(context.requestId, "HELLO WORLD");
};
runtime.registerHandler("test.handler", testHandler);
final removedHandler =
runtime.deregisterHandler<AwsS3Event>("test.handler");
expect(runtime.handlerExists("test.handler"), equals(false));
expect(removedHandler, equals(testHandler));
});
});
}