Limit retries in test to avoid timeout (#2765)

diff --git a/test/add/hosted/non_default_pub_server_test.dart b/test/add/hosted/non_default_pub_server_test.dart
index 75a4efd..fbe966e 100644
--- a/test/add/hosted/non_default_pub_server_test.dart
+++ b/test/add/hosted/non_default_pub_server_test.dart
@@ -42,9 +42,14 @@
     await d.appDir({}).create();
 
     await pubAdd(
-        args: ['foo', '--hosted-url', 'https://invalid-url.foo'],
-        error: contains('Could not resolve URL "https://invalid-url.foo".'),
-        exitCode: exit_codes.DATA);
+      args: ['foo', '--hosted-url', 'https://invalid-url.foo'],
+      error: contains('Could not resolve URL "https://invalid-url.foo".'),
+      exitCode: exit_codes.DATA,
+      environment: {
+        // Limit the retries - the url will never go valid.
+        'PUB_MAX_HTTP_RETRIES': '1',
+      },
+    );
 
     await d.appDir({}).validate();
     await d.dir(appPath, [