-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathcontext_test.dart
48 lines (41 loc) · 1.9 KB
/
context_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
46
47
48
import "dart:convert";
import "package:test/test.dart";
import 'package:aws_lambda_dart_runtime/runtime/context.dart';
import 'package:aws_lambda_dart_runtime/client/client.dart';
import 'common.dart';
void main() {
group('context', () {
test("Context gets initialized with a Platform.environment", () async {
final Map<String, String> environment = {
"_HANDLER": "foo",
"AWS_LAMBDA_FUNCTION_NAME": "bar",
"AWS_LAMBDA_FUNCTION_VERSION": "1",
"AWS_LAMBDA_LOG_GROUP_NAME": "foo",
"AWS_LAMBDA_LOG_STREAM_NAME": "foo",
"AWS_LAMBDA_FUNCTION_MEMORY_SIZE": "128",
"AWS_REGION": "eu-west-1",
"AWS_EXECUTION_ENV": "foo",
"AWS_ACCESS_KEY_ID": "secret",
"AWS_SECRET_ACCESS_KEY": "key",
"AWS_SESSION_TOKEN": "1234567890"
};
final headers = MockHttpHeaders();
final response = MockHttpClientResponse(200,
result: "", headers: headers, body: utf8.encode("{}"));
final nextInvocation = await NextInvocation.fromResponse(response);
final ctx = Context.fromNextInvocation(nextInvocation);
expect(ctx.handler, environment["_HANDLER"]);
expect(ctx.functionName, environment["AWS_LAMBDA_FUNCTION_NAME"]);
expect(ctx.functionVersion, environment["AWS_LAMBDA_FUNCTION_VERSION"]);
expect(ctx.logGroupName, environment["AWS_LAMBDA_LOG_GROUP_NAME"]);
expect(ctx.logStreamName, environment["AWS_LAMBDA_LOG_STREAM_NAME"]);
expect(ctx.functionMemorySize,
environment["AWS_LAMBDA_FUNCTION_MEMORY_SIZE"]);
expect(ctx.region, environment["AWS_REGION"]);
expect(ctx.executionEnv, environment["AWS_EXECUTION_ENV"]);
expect(ctx.accessKey, environment["AWS_ACCESS_KEY_ID"]);
expect(ctx.secretAccessKey, environment["AWS_SECRET_ACCESS_KEY"]);
expect(ctx.sessionToken, environment["AWS_SESSION_TOKEN"]);
});
}, skip: "the tests are not quite ready");
}