Fix dry-run tests for publishing by ensuring there is a server to reject requests (#2978)
diff --git a/test/lish/server_arg_overrides_publish_to_url_test.dart b/test/lish/server_arg_overrides_publish_to_url_test.dart
index 6d7929b..8e5d9c8 100644
--- a/test/lish/server_arg_overrides_publish_to_url_test.dart
+++ b/test/lish/server_arg_overrides_publish_to_url_test.dart
@@ -11,13 +11,20 @@
void main() {
test('an explicit --server argument overrides a "publish_to" url', () async {
+ // Create a real server that can reject requests because validators will
+ // try to ping it, and will use multiple retries when doing so.
+ final packageServer = await DescriptorServer.start();
+ final fakePackageServer = 'http://localhost:${packageServer.port}';
+
var pkg = packageMap('test_pkg', '1.0.0');
pkg['publish_to'] = 'http://pubspec.com';
await d.dir(appPath, [d.pubspec(pkg)]).create();
await runPub(
- args: ['lish', '--dry-run', '--server', 'http://arg.com'],
- output: contains('http://arg.com'),
+ args: ['lish', '--dry-run', '--server', fakePackageServer],
+ output: contains(fakePackageServer),
exitCode: exit_codes.DATA);
+
+ await packageServer.close();
});
}