Skip to content

Commit 5886146

Browse files
authored
[tests] increase timeout and wrap http client call (#3964)
1 parent 59ab953 commit 5886146

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

test/IntegrationTests/DotNetCliTests.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,16 @@ private static void ChangeDefaultProgramToHttpClient()
6565
{
6666
const string ProgramContent = @"
6767
using var httpClient = new HttpClient();
68-
httpClient.Timeout = TimeSpan.FromSeconds(5);
69-
using var response = await httpClient.GetAsync(""http://example.com"");
70-
Console.WriteLine(response.StatusCode);
68+
httpClient.Timeout = TimeSpan.FromSeconds(10);
69+
try
70+
{
71+
var response = await httpClient.GetAsync(""http://example.com"");
72+
Console.WriteLine(response.StatusCode);
73+
}
74+
catch (Exception e)
75+
{
76+
Console.WriteLine(e);
77+
}
7178
";
7279

7380
File.WriteAllText("Program.cs", ProgramContent);

test/test-applications/nuget-packages/TestApplication.NugetSample/Program.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@
1818
using System.Net.Http;
1919
#endif
2020

21-
var httpClient = new HttpClient();
22-
httpClient.Timeout = TimeSpan.FromSeconds(5);
23-
var response = await httpClient.GetAsync("http://example.com");
24-
Console.WriteLine(response.StatusCode);
21+
using var httpClient = new HttpClient();
22+
httpClient.Timeout = TimeSpan.FromSeconds(10);
23+
try
24+
{
25+
var response = await httpClient.GetAsync("http://example.com");
26+
Console.WriteLine(response.StatusCode);
27+
}
28+
catch (Exception e)
29+
{
30+
Console.WriteLine(e);
31+
}

0 commit comments

Comments
 (0)