OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'dart:convert' show UTF8; | 5 import 'dart:convert' show UTF8; |
6 | 6 |
7 import 'package:http/http.dart'; | 7 import 'package:http/http.dart'; |
8 import 'package:http/testing.dart'; | 8 import 'package:http/testing.dart'; |
9 import 'package:telemetry/crash_reporting.dart'; | 9 import 'package:telemetry/crash_reporting.dart'; |
10 import 'package:test/test.dart'; | 10 import 'package:test/test.dart'; |
11 import 'package:usage/usage.dart'; | 11 import 'package:usage/usage.dart'; |
12 | 12 |
13 void main() { | 13 void main() { |
14 group('crash_reporting', () { | 14 group('crash_reporting', () { |
15 MockClient mockClient; | 15 MockClient mockClient; |
16 | 16 |
17 Request request; | 17 Request request; |
18 | 18 |
19 setUp(() { | 19 setUp(() { |
20 mockClient = new MockClient((Request r) async { | 20 mockClient = new MockClient((Request r) async { |
21 request = r; | 21 request = r; |
22 return new Response('crash-report-001', 200); | 22 return new Response('crash-report-001', 200); |
23 }); | 23 }); |
24 }); | 24 }); |
25 | 25 |
26 test('CrashReportSender', () async { | 26 test('CrashReportSender', () async { |
27 AnalyticsMock analytics = new AnalyticsMock(); | 27 AnalyticsMock analytics = new AnalyticsMock()..enabled = false; |
28 CrashReportSender sender = | 28 CrashReportSender sender = new CrashReportSender( |
29 new CrashReportSender(analytics, httpClient: mockClient); | 29 analytics.trackingId, analytics, |
| 30 httpClient: mockClient); |
30 | 31 |
31 await sender.sendReport('test-error', stackTrace: StackTrace.current); | 32 await sender.sendReport('test-error', stackTrace: StackTrace.current); |
32 | 33 |
33 String body = UTF8.decode(request.bodyBytes); | 34 String body = UTF8.decode(request.bodyBytes); |
34 expect(body, contains('String')); // error.runtimeType | 35 expect(body, contains('String')); // error.runtimeType |
35 expect(body, contains(analytics.trackingId)); | 36 expect(body, contains(analytics.trackingId)); |
36 expect(body, contains('1.0.0')); | 37 expect(body, contains('1.0.0')); |
37 expect(body, contains(analytics.clientId)); | 38 expect(body, contains(analytics.clientId)); |
38 }); | 39 }); |
39 }); | 40 }); |
40 } | 41 } |
OLD | NEW |