Skip to content

Commit e417401

Browse files
committed
Add Cat Health test where Timestamp is false
_cat/health also supports ts=0 - elastic/elasticsearch#13508, but it's sufficient to only support the true/false form
1 parent 75ef83c commit e417401

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

src/Tests/Cat/CatHealth/CatHealthApiTests.cs

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Elasticsearch.Net;
1+
using System;
2+
using Elasticsearch.Net;
23
using FluentAssertions;
34
using Nest;
45
using Tests.Framework;
@@ -29,4 +30,39 @@ protected override void ExpectResponse(ICatResponse<CatHealthRecord> response)
2930
}
3031
}
3132

33+
[Collection(TypeOfCluster.ReadOnly)]
34+
public class CatHealthNoTimestampApiTests : ApiIntegrationTestBase<ICatResponse<CatHealthRecord>, ICatHealthRequest, CatHealthDescriptor, CatHealthRequest>
35+
{
36+
public CatHealthNoTimestampApiTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluster, usage) { }
37+
protected override LazyResponses ClientUsage() => Calls(
38+
fluent: (client, f) => client.CatHealth(f),
39+
fluentAsync: (client, f) => client.CatHealthAsync(f),
40+
request: (client, r) => client.CatHealth(r),
41+
requestAsync: (client, r) => client.CatHealthAsync(r)
42+
);
43+
44+
protected override bool ExpectIsValid => true;
45+
protected override int ExpectStatusCode => 200;
46+
protected override HttpMethod HttpMethod => HttpMethod.GET;
47+
protected override string UrlPath => "/_cat/health?ts=false";
48+
49+
protected override Func<CatHealthDescriptor, ICatHealthRequest> Fluent => s => s
50+
.Ts(false);
51+
52+
protected override CatHealthRequest Initializer => new CatHealthRequest
53+
{
54+
Ts = false
55+
};
56+
57+
protected override void ExpectResponse(ICatResponse<CatHealthRecord> response)
58+
{
59+
response.Records.Should().NotBeEmpty().And.Contain(a => !string.IsNullOrEmpty(a.Status));
60+
61+
foreach (var record in response.Records)
62+
{
63+
record.Timestamp.Should().BeNullOrWhiteSpace();
64+
}
65+
}
66+
}
67+
3268
}

0 commit comments

Comments
 (0)