Skip to content

Commit 3773dde

Browse files
committed
added test that getmany throws on connection failures
1 parent 94ac52a commit 3773dde

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

src/Tests/Document/Multiple/MultiGet/GetManyApiTests.cs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using System.Text;
55
using System.Threading.Tasks;
6+
using Elasticsearch.Net;
67
using FluentAssertions;
78
using Nest;
89
using Tests.Framework;
@@ -25,8 +26,7 @@ public GetManyApiTests(ReadOnlyCluster cluster)
2526
_client = _cluster.Client;
2627
}
2728

28-
[I]
29-
public void UsesDefaultIndexAndInferredType()
29+
[I] public void UsesDefaultIndexAndInferredType()
3030
{
3131
var response = _client.GetMany<Developer>(_ids);
3232
response.Count().Should().Be(10);
@@ -39,8 +39,7 @@ public void UsesDefaultIndexAndInferredType()
3939
}
4040
}
4141

42-
[I]
43-
public async Task UsesDefaultIndexAndInferredTypeAsync()
42+
[I] public async Task UsesDefaultIndexAndInferredTypeAsync()
4443
{
4544
var response = await _client.GetManyAsync<Developer>(_ids);
4645
response.Count().Should().Be(10);
@@ -52,5 +51,26 @@ public async Task UsesDefaultIndexAndInferredTypeAsync()
5251
hit.Found.Should().BeTrue();
5352
}
5453
}
54+
55+
[I] public async Task CanHandleNotFoundResponses()
56+
{
57+
var response = await _client.GetManyAsync<Developer>(_ids.Select(i=>i*100));
58+
response.Count().Should().Be(10);
59+
foreach (var hit in response)
60+
{
61+
hit.Index.Should().NotBeNullOrWhiteSpace();
62+
hit.Type.Should().NotBeNullOrWhiteSpace();
63+
hit.Id.Should().NotBeNullOrWhiteSpace();
64+
hit.Found.Should().BeFalse();
65+
}
66+
}
67+
[I] public void ThrowsExceptionOnConnectionError()
68+
{
69+
if (TestClient.RunningFiddler) return; //fiddler meddles here
70+
71+
var client = new ElasticClient(TestClient.CreateSettings(port: 9500));
72+
Action response = () => client.GetMany<Developer>(_ids.Select(i=>i*100));
73+
response.ShouldThrow<ElasticsearchClientException>();
74+
}
5575
}
5676
}

src/Tests/Framework/TestClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace Tests.Framework
1717
{
1818
public static class TestClient
1919
{
20-
private static readonly bool RunningFiddler = Process.GetProcessesByName("fiddler").Any();
20+
public static readonly bool RunningFiddler = Process.GetProcessesByName("fiddler").Any();
2121
public static readonly ITestConfiguration Configuration = LoadConfiguration();
2222

2323
public static readonly ConnectionSettings GlobalDefaultSettings = CreateSettings();

0 commit comments

Comments
 (0)