Index: utils/tests/pub/test_pub.dart |
diff --git a/utils/tests/pub/test_pub.dart b/utils/tests/pub/test_pub.dart |
index 78d198ae0da8e43644995f3f9511f2cfe4bf23e2..a1bef634b7a7422487c48630d2954956e4213a38 100644 |
--- a/utils/tests/pub/test_pub.dart |
+++ b/utils/tests/pub/test_pub.dart |
@@ -19,10 +19,12 @@ import 'dart:uri'; |
import '../../../pkg/oauth2/lib/oauth2.dart' as oauth2; |
import '../../../pkg/path/lib/path.dart' as path; |
import '../../../pkg/unittest/lib/unittest.dart'; |
+import '../../../pkg/http/lib/testing.dart'; |
import '../../lib/file_system.dart' as fs; |
import '../../pub/entrypoint.dart'; |
import '../../pub/git_source.dart'; |
import '../../pub/hosted_source.dart'; |
+import '../../pub/http.dart'; |
import '../../pub/io.dart'; |
import '../../pub/sdk_source.dart'; |
import '../../pub/system_cache.dart'; |
@@ -708,6 +710,18 @@ void ensureGit() { |
}); |
} |
+/// Use [client] as the mock HTTP client for this test. |
+/// |
+/// Note that this will only affect HTTP requests made via http.dart in the |
+/// parent process. |
+void useMockClient(MockClient client) { |
+ var oldInnerClient = httpClient.inner; |
+ httpClient.inner = client; |
+ _scheduleCleanup((_) { |
+ httpClient.inner = oldInnerClient; |
+ }); |
+} |
+ |
Future<Directory> _setUpSandbox() => createTempDir(); |
Future _runScheduled(Directory parentDir, List<_ScheduledEvent> scheduled) { |