Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhnroyal committed Jan 21, 2024
1 parent 997b4ec commit 1f7a81a
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 16 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ jobs:
- name: '[Verify step] Analyze Flutter packages'
run: melos exec $(eval echo $IGNORED_PACKAGES) --flutter -- "flutter analyze --fatal-infos"
- name: '[Verify step] Publish dry-run'
run: melos exec $(eval echo $IGNORED_PACKAGES) --ignore="*example*" --ignore="dio_tests" -- "dart pub publish --dry-run"
run: melos exec $(eval echo $IGNORED_PACKAGES) --ignore="*example*" --ignore="dio_test" -- "dart pub publish --dry-run"
- name: '[Verify step] Test Dart packages [VM]'
run: melos exec $(eval echo $IGNORED_PACKAGES) --ignore="*example*" --no-flutter -- "MELOS_ROOT_PATH/scripts/dart_test.sh --platform=vm"
run: melos exec $(eval echo $IGNORED_PACKAGES) --dir-exists="test" --no-flutter -- "MELOS_ROOT_PATH/scripts/dart_test.sh --platform=vm"
- name: '[Verify step] Test Dart packages [Chrome]'
run: melos exec $(eval echo $IGNORED_PACKAGES) --ignore="*example*" --no-flutter -- "MELOS_ROOT_PATH/scripts/dart_test.sh --platform=chrome"
run: melos exec $(eval echo $IGNORED_PACKAGES) --dir-exists="test" --no-flutter -- "MELOS_ROOT_PATH/scripts/dart_test.sh --platform=chrome"
- name: '[Verify step] Test Dart packages [Firefox]'
run: melos exec $(eval echo $IGNORED_PACKAGES) --ignore="*example*" --no-flutter -- "MELOS_ROOT_PATH/scripts/dart_test.sh --platform=firefox"
run: melos exec $(eval echo $IGNORED_PACKAGES) --dir-exists="test" --no-flutter -- "MELOS_ROOT_PATH/scripts/dart_test.sh --platform=firefox"
- name: '[Verify step] Test Flutter packages'
run: melos exec $(eval echo $IGNORED_PACKAGES) --ignore="*example*" --flutter -- "flutter test"
run: melos exec $(eval echo $IGNORED_PACKAGES) --dir-exists="test" --flutter -- "flutter test"
4 changes: 2 additions & 2 deletions dio/test/basic_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import 'dart:async';
import 'dart:io';

import 'package:dio/dio.dart';
import 'package:dio/src/utils.dart';
import 'package:test/test.dart';

import 'mock/adapters.dart';
import 'utils.dart';

void main() {
test('send with an invalid URL', () async {
Expand All @@ -15,7 +15,7 @@ void main() {
allOf([
isA<DioException>(),
(DioException e) => e.type == (DioExceptionType.connectionError),
if (!isWeb) (DioException e) => e.error is SocketException,
if (!kIsWeb) (DioException e) => e.error is SocketException,
]),
),
);
Expand Down
3 changes: 1 addition & 2 deletions dio/test/cors_tests.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import 'package:dio/dio.dart';
import 'package:dio_test/util.dart';
import 'package:test/test.dart';

import '../../dio_test/lib/src/matcher.dart';

// Test that browsers can correctly classify requests as
// either "simple" or "preflighted". Reference:
// https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#simple_requests
Expand Down
1 change: 1 addition & 0 deletions dio/test/test_suite_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:dio/dio.dart';
import 'package:dio/src/utils.dart';
import 'package:dio_test/tests.dart';

void main() {
Expand Down
7 changes: 6 additions & 1 deletion dio_test/lib/src/matcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ Matcher matchesDioException(
);
if (stackTraceContains != null) {
base = base.having(
(e) => e.stackTrace.toString(),
(e) {
print('########');
print(e.stackTrace);
print('########');
return e.stackTrace.toString();
},
'stackTrace',
contains(stackTraceContains),
);
Expand Down
2 changes: 0 additions & 2 deletions dio_test/lib/src/test/parameter_tests.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import 'package:dio/dio.dart';
import 'package:test/test.dart';

import '../utils.dart';

void parameterTests(
Dio Function() create,
) {
Expand Down
4 changes: 2 additions & 2 deletions dio_test/lib/src/test/redirect_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void redirectTests(
);
expect(response.isRedirect, isTrue);

if (!isWeb) {
if (!kIsWeb) {
// Redirects are not supported in web.
// Rhe browser will follow the redirects automatically.
expect(response.redirects.length, 1);
Expand All @@ -40,7 +40,7 @@ void redirectTests(
);
expect(response.isRedirect, isTrue);

if (!isWeb) {
if (!kIsWeb) {
// Redirects are not supported in web.
// The browser will follow the redirects automatically.
expect(response.redirects.length, 3);
Expand Down
3 changes: 2 additions & 1 deletion dio_test/lib/src/test/status_code_tests.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:dio/dio.dart';
import 'package:dio_test/src/utils.dart';
import 'package:test/test.dart';

import '../matcher.dart';
Expand All @@ -19,7 +20,7 @@ void statusCodeTests(
dio.get('/status/$code'),
throwsDioException(
DioExceptionType.badResponse,
stackTraceContains: 'test/status_code_tests.dart',
stackTraceContains: kIsWeb ? null : 'test/status_code_tests.dart',
matcher: isA<DioException>().having(
(e) => e.response!.statusCode,
'statusCode',
Expand Down
2 changes: 1 addition & 1 deletion dio_test/lib/src/utils.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const isWeb = bool.hasEnvironment('dart.library.js_util')
const kIsWeb = bool.hasEnvironment('dart.library.js_util')
? bool.fromEnvironment('dart.library.js_util')
: identical(0, 0.0);

0 comments on commit 1f7a81a

Please sign in to comment.