Skip to content

Commit 6f07a55

Browse files
committed
Fix failing unit tests after refactoring of IndexNameResolver
1 parent 40e25c6 commit 6f07a55

File tree

6 files changed

+14
-7
lines changed

6 files changed

+14
-7
lines changed

src/Nest/CommonAbstractions/Infer/IndexName/IndexNameResolver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public IndexNameResolver(IConnectionSettingsValues connectionSettings)
1717
public string Resolve(IndexName i)
1818
{
1919
if (i == null || string.IsNullOrEmpty(i.Name))
20-
return this.Resolve((Type)null);
20+
return this.Resolve(i.Type);
2121
ValidateIndexName(i.Name);
2222
return i.Name;
2323
}

src/Tests/ClientConcepts/Exceptions/ExceptionTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,11 @@ public void ClientTestWhenThrowExceptionsDisabled()
8787
[U]
8888
public void DispatchIndicatesMissingRouteValues()
8989
{
90-
var settings = new ConnectionSettings(new Uri("http://doesntexist:9200"));
90+
var settings = new ConnectionSettings(new Uri("http://doesntexist:9200"))
91+
.DefaultIndex("default-index");
9192
var client = new ElasticClient(settings);
9293

93-
Action dispatch = () => client.Index(new Project());
94+
Action dispatch = () => client.Index(new Project(), i => i.Index(null));
9495
var ce = dispatch.ShouldThrow<ArgumentException>();
9596
ce.Should().NotBeNull();
9697
ce.Which.Message.Should().Contain("index=<NULL>");

src/Tests/ClientConcepts/LowLevel/Connecting.doc.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ [U]public async Task UsingOnRequestCompletedForLogging()
215215
var list = new List<string>();
216216
var connectionPool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
217217
var settings = new ConnectionSettings(connectionPool, new InMemoryConnection())
218+
.DefaultIndex("default-index")
218219
.DisableDirectStreaming()
219220
.OnRequestCompleted(response =>
220221
{
@@ -247,6 +248,8 @@ [U]public async Task UsingOnRequestCompletedForLogging()
247248
var client = new ElasticClient(settings);
248249

249250
var syncResponse = client.Search<object>(s => s
251+
.AllTypes()
252+
.AllIndices()
250253
.Scroll("2m")
251254
.Sort(ss => ss
252255
.Ascending(SortSpecialField.DocumentIndexOrder)
@@ -256,6 +259,8 @@ [U]public async Task UsingOnRequestCompletedForLogging()
256259
list.Count.Should().Be(2);
257260

258261
var asyncResponse = await client.SearchAsync<object>(s => s
262+
.AllTypes()
263+
.AllIndices()
259264
.Scroll("2m")
260265
.Sort(ss => ss
261266
.Ascending(SortSpecialField.DocumentIndexOrder)

src/Tests/Framework/TestClient.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ public static IElasticClient GetFixedReturnClient(
101101

102102
var connection = new InMemoryConnection(fixedResult, statusCode, exception);
103103
var connectionPool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
104-
var defaultSettings = new ConnectionSettings(connectionPool, connection);
104+
var defaultSettings = new ConnectionSettings(connectionPool, connection)
105+
.DefaultIndex("default-index");
105106
var settings = (modifySettings != null) ? modifySettings(defaultSettings) : defaultSettings;
106107
return new ElasticClient(settings);
107108
}

src/Tests/Framework/VirtualClustering/SealedVirtualCluster.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ public SealedVirtualCluster(VirtualCluster cluster, IConnectionPool pool, Testab
2020
}
2121

2222
private ConnectionSettings CreateSettings() =>
23-
new ConnectionSettings(this._connectionPool, this._connection);
23+
new ConnectionSettings(this._connectionPool, this._connection).DefaultIndex("default-index");
2424

2525
public VirtualizedCluster AllDefaults() =>
2626
new VirtualizedCluster(this._cluster, this._connectionPool, this._dateTimeProvider, CreateSettings());
2727

2828
public VirtualizedCluster Settings(Func<ConnectionSettings, ConnectionSettings> selector) =>
2929
new VirtualizedCluster(this._cluster, this._connectionPool, this._dateTimeProvider, selector(CreateSettings()));
3030
}
31-
}
31+
}

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: m
33
# the elasticsearch version that should be started
44
elasticsearch_version: 2.2.0
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)