Skip to content

Update dev deps #1158

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

Merged
merged 12 commits into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dart/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ dependencies:
path: ../../dart

dev_dependencies:
lints: ^1.0.1
lints: ^2.0.0
4 changes: 2 additions & 2 deletions dart/example_web/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies:
path: ../../dart

dev_dependencies:
build_runner: ^2.1.7
build_runner: ^2.1.8
build_web_compilers: ^3.2.2
lints: ^1.0.1
lints: ^2.0.0
webdev: ^2.7.6
1 change: 0 additions & 1 deletion dio/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ dev_dependencies:
test: ^1.21.1
coverage: ^1.3.0
mockito: ^5.1.0
http: ^0.13.4
10 changes: 9 additions & 1 deletion dio/test/mocks/mock_http_client_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ typedef MockFetchMethod = Future<ResponseBody> Function(
Future<dynamic>? cancelFuture,
);

typedef MockCloseMethod = void Function({bool force});

class MockHttpClientAdapter extends HttpClientAdapter
with NoSuchMethodProvider {
MockHttpClientAdapter(this.mockFetchMethod);
MockHttpClientAdapter(this.mockFetchMethod, {this.mockCloseMethod});

final MockFetchMethod mockFetchMethod;
final MockCloseMethod? mockCloseMethod;

@override
Future<ResponseBody> fetch(
Expand All @@ -24,4 +27,9 @@ class MockHttpClientAdapter extends HttpClientAdapter
) {
return mockFetchMethod(options, requestStream, cancelFuture);
}

@override
void close({bool force = false}) {
return mockCloseMethod?.call(force: force);
}
}
37 changes: 21 additions & 16 deletions dio/test/sentry_dio_client_adapter_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import 'package:dio/dio.dart';
import 'package:http/http.dart';
import 'package:mockito/mockito.dart';
import 'package:sentry/sentry.dart';
import 'package:sentry_dio/src/sentry_dio_client_adapter.dart';
import 'package:test/test.dart';
Expand Down Expand Up @@ -47,16 +45,10 @@ void main() {
});

test('close does get called for user defined client', () async {
final mockHub = MockHub();
final client = createCloseClient();
final sut = fixture.getSut(client: client);

final mockClient = CloseableMockClient();

final client = SentryHttpClient(client: mockClient, hub: mockHub);
client.close();

expect(mockHub.addBreadcrumbCalls.length, 0);
expect(mockHub.captureExceptionCalls.length, 0);
verify(mockClient.close());
sut.close(force: true);
});

test('no captured span if tracing disabled', () async {
Expand Down Expand Up @@ -96,7 +88,18 @@ MockHttpClientAdapter createThrowingClient() {
);
}

class CloseableMockClient extends Mock implements BaseClient {}
void _close({bool force = false}) {
expect(force, true);
}

MockHttpClientAdapter createCloseClient() {
return MockHttpClientAdapter(
(_, __, ___) async {
return ResponseBody.fromString('', 200);
},
mockCloseMethod: _close,
);
}

class Fixture {
Dio getSut({
Expand All @@ -121,10 +124,12 @@ class Fixture {
final MockHub hub = MockHub();

MockHttpClientAdapter getClient({int statusCode = 200, String? reason}) {
return MockHttpClientAdapter((options, _, __) async {
expect(options.uri, requestUri);
return ResponseBody.fromString('', statusCode);
});
return MockHttpClientAdapter(
(options, _, __) async {
expect(options.uri, requestUri);
return ResponseBody.fromString('', statusCode);
},
);
}
}

Expand Down
4 changes: 0 additions & 4 deletions dio/test/tracing_client_adapter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// The lint above is okay, because we're using another Sentry package

import 'package:dio/dio.dart';
import 'package:http/http.dart';
import 'package:mockito/mockito.dart';
import 'package:sentry/sentry.dart';
import 'package:sentry/src/sentry_tracer.dart';
import 'package:sentry_dio/src/tracing_client_adapter.dart';
Expand Down Expand Up @@ -153,8 +151,6 @@ MockHttpClientAdapter createThrowingClient() {
);
}

class CloseableMockClient extends Mock implements BaseClient {}

class Fixture {
final _options = SentryOptions(dsn: fakeDsn);
late Hub _hub;
Expand Down
4 changes: 2 additions & 2 deletions e2e_test/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies:
sentry:
path:
./../dart
http: ^0.13.3
http: ^0.13.0

dev_dependencies:
lints: ^1.0.1
lints: ^2.0.0
2 changes: 1 addition & 1 deletion flutter/example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include: package:pedantic/analysis_options.yaml
include: package:flutter_lints/flutter.yaml

analyzer:
errors:
Expand Down
10 changes: 5 additions & 5 deletions flutter/example/integration_test/integration_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void main() {
await tester.pumpWidget(SentryScreenshotWidget(
child: DefaultAssetBundle(
bundle: SentryAssetBundle(enableStructuredDataTracing: true),
child: MyApp(),
child: const MyApp(),
)));
await tester.pumpAndSettle();
});
Expand All @@ -34,20 +34,20 @@ void main() {
final event = SentryEvent();
final sentryId = await Sentry.captureEvent(event);

expect(sentryId != SentryId.empty(), true);
expect(sentryId != const SentryId.empty(), true);
});

testWidgets('setup sentry and capture exception', (tester) async {
await setupSentryAndApp(tester);

try {
throw SentryException(
throw const SentryException(
type: 'StarError', value: 'I have a bad feeling about this...');
} catch (exception, stacktrace) {
final sentryId =
await Sentry.captureException(exception, stackTrace: stacktrace);

expect(sentryId != SentryId.empty(), true);
expect(sentryId != const SentryId.empty(), true);
}
});

Expand All @@ -56,7 +56,7 @@ void main() {

final sentryId = await Sentry.captureMessage('hello world!');

expect(sentryId != SentryId.empty(), true);
expect(sentryId != const SentryId.empty(), true);
});

testWidgets('setup sentry and capture user feedback', (tester) async {
Expand Down
Loading