-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTimeoutTests.cs
More file actions
43 lines (37 loc) · 1.33 KB
/
TimeoutTests.cs
File metadata and controls
43 lines (37 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System;
using System.IO;
using System.Threading.Tasks;
using System.Xml.Linq;
using Xunit;
namespace Https.Tests
{
[Collection(nameof(WebHostFixture))]
public class TimeoutTests
{
readonly WebHostFixture _fixture;
public TimeoutTests(WebHostFixture fixture) =>
_fixture = fixture;
[Fact]
public async Task TimeoutTest_ShouldRespectTimeoutOption()
{
var delay = 1_000;
var args = new[]
{
"post", $"{_fixture.HttpUrl}/Timeout?delay={delay * 4}", $"--timeout={TimeSpan.FromMilliseconds(delay)}"
};
var result = await Https.ExecuteAsync(args);
Assert.Equal(1, result.ExitCode);
var stdout = new StreamReader(result.StdOut).ReadToEnd();
var expectedOut = "";
Assert.Equal(expectedOut, stdout);
var stderr = new StreamReader(result.StdErr).ReadToEnd();
var expectedErr = string.Join(Environment.NewLine, new[]
{
"The request was canceled due to the configured HttpClient.Timeout of 1 seconds elapsing.",
"Request failed to complete within timeout. Try increasing the timeout with the --timeout flag",
""
});
Assert.Equal(expectedErr, stderr);
}
}
}