Skip to content

Commit caa3af3

Browse files
committed
Fix failing exception tests when using HttpClient (.NET CoreCLR)
1 parent d3f89ba commit caa3af3

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/Tests/ClientConcepts/Exceptions/ExceptionTests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ public void ServerTestWhenThrowExceptionsEnabled()
1717
.ThrowExceptions();
1818
var client = new ElasticClient(settings);
1919
var exception = Assert.Throws<ElasticsearchClientException>(() => client.GetMapping<Project>(s => s.Index("doesntexist")));
20+
#if DOTNETCORE
21+
// HttpClient does not throw on "known error" status codes (i.e. 404) thus the inner exception should not be set
22+
exception.InnerException.Should().BeNull();
23+
#else
2024
exception.InnerException.Should().NotBeNull();
25+
#endif
2126
exception.Response.Should().NotBeNull();
2227
exception.Response.ServerError.Should().NotBeNull();
2328
exception.Response.ServerError.Status.Should().BeGreaterThan(0);
@@ -40,7 +45,12 @@ public void ServerTestWhenThrowExceptionsDisabled()
4045
var settings = new ConnectionSettings(new Uri($"http://{TestClient.Host}:9200"));
4146
var client = new ElasticClient(settings);
4247
var response = client.GetMapping<Project>(s => s.Index("doesntexist"));
48+
#if DOTNETCORE
49+
// HttpClient does not throw on "known error" status codes (i.e. 404) thus OriginalException should not be set
50+
response.CallDetails.OriginalException.Should().BeNull();
51+
#else
4352
response.CallDetails.OriginalException.Should().NotBeNull();
53+
#endif
4454
response.CallDetails.ServerError.Should().NotBeNull();
4555
response.CallDetails.ServerError.Status.Should().BeGreaterThan(0);
4656
}

src/Tests/tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# mode either u (unit test), i (integration test) or m (mixed mode)
2-
mode: u
2+
mode: i
33
# the elasticsearch version that should be started
44
elasticsearch_version: 2.0.1
55
# whether we want to forcefully reseed on the node, if you are starting the tests with a node already running

0 commit comments

Comments
 (0)