Skip to content

Commit

Permalink
fix(tests): clobbered tests from library-level exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
micimize committed Oct 16, 2019
1 parent 9858886 commit f76e165
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.flutter.plugins;

import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugins.connectivity.ConnectivityPlugin;
import io.flutter.plugins.pathprovider.PathProviderPlugin;

/**
Expand All @@ -11,6 +12,7 @@ public static void registerWith(PluginRegistry registry) {
if (alreadyRegisteredWith(registry)) {
return;
}
ConnectivityPlugin.registerWith(registry.registrarFor("io.flutter.plugins.connectivity.ConnectivityPlugin"));
PathProviderPlugin.registerWith(registry.registrarFor("io.flutter.plugins.pathprovider.PathProviderPlugin"));
}

Expand Down
2 changes: 2 additions & 0 deletions examples/starwars/ios/Runner/GeneratedPluginRegistrant.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
//

#import "GeneratedPluginRegistrant.h"
#import <connectivity/ConnectivityPlugin.h>
#import <path_provider/PathProviderPlugin.h>

@implementation GeneratedPluginRegistrant

+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry {
[FLTConnectivityPlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTConnectivityPlugin"]];
[FLTPathProviderPlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTPathProviderPlugin"]];
}

Expand Down
25 changes: 11 additions & 14 deletions packages/graphql/lib/src/exceptions/io_network_exception.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,19 @@ import 'dart:io' show SocketException;
import 'dart:io';
import './network_exception_stub.dart' as stub;

class NetworkException extends stub.NetworkException {
SocketException wrappedException;
export './network_exception_stub.dart' show NetworkException;

Uri uri;

NetworkException.from(this.wrappedException)
: uri = Uri(
scheme: 'http',
host: wrappedException.address.host,
port: wrappedException.port,
);
}

NetworkException translateNetworkFailure(dynamic failure) {
stub.NetworkException translateNetworkFailure(dynamic failure) {
if (failure is SocketException) {
return NetworkException.from(failure);
return stub.NetworkException(
wrappedException: failure,
message: failure.message,
uri: Uri(
scheme: 'http',
host: failure.address.host,
port: failure.port,
),
);
}
return stub.translateNetworkFailure(failure);
}
22 changes: 20 additions & 2 deletions packages/graphql/test/link/http/link_http_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "dart:async";
import "dart:convert";

import 'package:graphql/client.dart';
import 'package:graphql/internal.dart';
import 'package:graphql/src/link/http/link_http.dart';
import 'package:graphql/src/link/link.dart';
Expand Down Expand Up @@ -340,11 +341,17 @@ void main() {

expect(
exception,
const TypeMatcher<NetworkException>(),
);

expect(
(exception as NetworkException).wrappedException,
const TypeMatcher<http.ClientException>(),
);

expect(
exception.toString(),
'Invalid response body: {}',
'Failed to connect to /graphql-test: Invalid response body: {}',
);
});

Expand Down Expand Up @@ -375,11 +382,17 @@ void main() {

expect(
exception,
const TypeMatcher<NetworkException>(),
);

expect(
(exception as NetworkException).wrappedException,
const TypeMatcher<http.ClientException>(),
);

expect(
exception.toString(),
'Network Error: 400 {}',
'Failed to connect to /graphql-test: Network Error: 400 {}',
);
});

Expand Down Expand Up @@ -439,6 +452,11 @@ void main() {

expect(
exception,
const TypeMatcher<UnhandledFailureWrapper>(),
);

expect(
(exception as UnhandledFailureWrapper).failure,
const TypeMatcher<FormatException>(),
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ export "FLUTTER_TARGET=lib/main.dart"
export "FLUTTER_BUILD_DIR=build"
export "SYMROOT=${SOURCE_ROOT}/../build/ios"
export "FLUTTER_FRAMEWORK_DIR=/Users/mjr/flutter/bin/cache/artifacts/engine/ios"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"

0 comments on commit f76e165

Please sign in to comment.