Skip to content

Commit

Permalink
Remove wonky logic in favor of a parameter to the test class construc…
Browse files Browse the repository at this point in the history
…tor (#2574)
  • Loading branch information
nr-ahemsath authored Jun 26, 2024
1 parent d96e29f commit 3b61279
Showing 1 changed file with 4 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,12 @@ protected enum ClientType
const string SyncMethodSkipReason = "Synchronous methods are deprecated in latest Elastic.Clients.Elasticsearch";


protected ElasticsearchTestsBase(TFixture fixture, ITestOutputHelper output, ClientType clientType) : base(fixture)
protected ElasticsearchTestsBase(TFixture fixture, ITestOutputHelper output, ClientType clientType, bool syncMethodsOk = true) : base(fixture)
{
_fixture = fixture;
_fixture.TestLogger = output;
_clientType = clientType;

// non-async methods are deprecated in the latest Elastic.Clients.Elasticsearch versions
if (_clientType != ClientType.ElasticClients ||
(_fixture.GetType() != typeof(ConsoleDynamicMethodFixtureCoreLatest) && _fixture.GetType() != typeof(ConsoleDynamicMethodFixtureFWLatest)))
{
_syncMethodsOk = true;
}
else
{
_syncMethodsOk = false;
}
_syncMethodsOk = syncMethodsOk;

_host = GetHostFromElasticServer(_clientType);

Expand Down Expand Up @@ -340,7 +330,7 @@ public ElasticsearchNetTestsCoreOldest(ConsoleDynamicMethodFixtureCoreOldest fix
public class ElasticsearchElasticClientTestsFWLatest : ElasticsearchTestsBase<ConsoleDynamicMethodFixtureFWLatest>
{
public ElasticsearchElasticClientTestsFWLatest(ConsoleDynamicMethodFixtureFWLatest fixture, ITestOutputHelper output)
: base(fixture, output, ClientType.ElasticClients)
: base(fixture, output, ClientType.ElasticClients, syncMethodsOk : false)
{
}
}
Expand All @@ -358,7 +348,7 @@ public ElasticsearchElasticClientTestsFW462(ConsoleDynamicMethodFixtureFW462 fix
public class ElasticsearchElasticClientTestsCoreLatest : ElasticsearchTestsBase<ConsoleDynamicMethodFixtureCoreLatest>
{
public ElasticsearchElasticClientTestsCoreLatest(ConsoleDynamicMethodFixtureCoreLatest fixture, ITestOutputHelper output)
: base(fixture, output, ClientType.ElasticClients)
: base(fixture, output, ClientType.ElasticClients, syncMethodsOk: false)
{
}
}
Expand Down

0 comments on commit 3b61279

Please sign in to comment.