-
-
Notifications
You must be signed in to change notification settings - Fork 276
Fixes tests and deprecation warnings for Dart2 #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
965da2c
1208ab4
40b9980
68d2e4c
c1e6a0b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| .DS_Store | ||
| .atom/ | ||
| .packages | ||
| .pub/ | ||
| .dart_tool/ | ||
| build/ | ||
| packages | ||
| pubspec.lock | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,6 @@ import 'dart:convert'; | |
| import 'dart:io'; | ||
|
|
||
| import 'package:http/http.dart'; | ||
| import 'package:mockito/mockito.dart'; | ||
| import 'package:quiver/time.dart'; | ||
| import 'package:sentry/sentry.dart'; | ||
| import 'package:test/test.dart'; | ||
|
|
@@ -32,8 +31,8 @@ void main() { | |
| String postUri; | ||
| Map<String, String> headers; | ||
| List<int> body; | ||
| when(httpMock.post(any, headers: any, body: any)) | ||
| .thenAnswer((Invocation invocation) { | ||
| httpMock.answerWith((Invocation invocation) { | ||
| if (invocation.memberName == #close) return null; | ||
| postUri = invocation.positionalArguments.single; | ||
| headers = invocation.namedArguments[#headers]; | ||
| body = invocation.namedArguments[#body]; | ||
|
|
@@ -79,13 +78,13 @@ void main() { | |
|
|
||
| expect(headers, expectedHeaders); | ||
|
|
||
| Map<String, dynamic> json; | ||
| Map<String, dynamic> data; | ||
| if (compressPayload) { | ||
| json = JSON.decode(UTF8.decode(GZIP.decode(body))); | ||
| data = json.decode(utf8.decode(GZIP.decode(body))); | ||
| } else { | ||
| json = JSON.decode(UTF8.decode(body)); | ||
| data = json.decode(utf8.decode(body)); | ||
| } | ||
| final Map<String, dynamic> stacktrace = json.remove('stacktrace'); | ||
| final Map<String, dynamic> stacktrace = data.remove('stacktrace'); | ||
| expect(stacktrace['frames'], const isInstanceOf<List>()); | ||
| expect(stacktrace['frames'], isNotEmpty); | ||
|
|
||
|
|
@@ -98,7 +97,7 @@ void main() { | |
| expect(topFrame['in_app'], true); | ||
| expect(topFrame['filename'], 'sentry_test.dart'); | ||
|
|
||
| expect(json, { | ||
| expect(data, { | ||
| 'project': '1', | ||
| 'event_id': 'X' * 32, | ||
| 'timestamp': '2017-01-02T00:00:00', | ||
|
|
@@ -128,8 +127,7 @@ void main() { | |
| final MockClient httpMock = new MockClient(); | ||
| final Clock fakeClock = new Clock.fixed(new DateTime(2017, 1, 2)); | ||
|
|
||
| when(httpMock.post(any, headers: any, body: any)) | ||
| .thenAnswer((Invocation invocation) { | ||
| httpMock.answerWith((Invocation invocation) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think here we can also assert that only |
||
| return new Response('', 401, headers: <String, String>{ | ||
| 'x-sentry-error': 'Invalid api key', | ||
| }); | ||
|
|
@@ -199,4 +197,16 @@ void main() { | |
| }); | ||
| } | ||
|
|
||
| class MockClient extends Mock implements Client {} | ||
| typedef Answer = dynamic Function(Invocation invocation); | ||
|
|
||
| class MockClient implements Client { | ||
| Answer _answer; | ||
|
|
||
| void answerWith(Answer answer) { | ||
| _answer = answer; | ||
| } | ||
|
|
||
| noSuchMethod(Invocation invocation) { | ||
| return _answer(invocation); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| #!/bin/sh | ||
| # Temporary workaround until Pub supports --preview-dart-2 flag | ||
| set -e | ||
| for filename in test/*_test.dart; do | ||
| dart --preview-dart-2 --enable_asserts "$filename" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's |
||
| done | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we assert after this line that
memberNameis#post? Also, let's use{ }for theifblock so that thereturnstatement gets its own line.