-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy paths3_event.dart
30 lines (25 loc) · 1.13 KB
/
s3_event.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
import 'dart:convert';
import 'dart:io' show File;
import 'package:aws_lambda_dart_runtime/aws_lambda_dart_runtime.dart';
import "package:test/test.dart";
final file = 'data/s3_event.json';
final String contents = new File(file).readAsStringSync();
final Map<String, dynamic> json = jsonDecode(contents);
void main() {
group("s3_default", () {
test("json got parsed and creates an event", () async {
final event = AwsS3Event.fromJson(json);
expect(event.records[0].eventVersion, equals("2.0"));
expect(event.records[0].eventSource, equals("aws:s3"));
expect(event.records[0].awsRegion, equals("eu-west-1"));
expect(event.records[0].eventTime,
equals(DateTime.parse("1970-01-01T00:00:00.000Z")));
expect(event.records[0].eventName, equals("ObjectCreated:Put"));
expect(event.records[0].userIdentity.principalId, equals("EXAMPLE"));
expect(event.records[0].requestParameters["sourceIPAddress"],
equals("127.0.0.1"));
expect(event.records[0].s3.s3SchemaVersion, equals("1.0"));
expect(event.records[0].s3.configurationId, equals("testConfigRule"));
});
});
}