Skip to content

Commit aba8dda

Browse files
committed
more test fixes
1 parent 9525f38 commit aba8dda

File tree

1 file changed

+32
-5
lines changed

1 file changed

+32
-5
lines changed

tests/NRedisStack.Tests/Search/SearchTests.cs

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,21 +223,26 @@ public void TestAggregationsLoad(string endpointId)
223223
ft.Create("idx", new(), sc);
224224

225225
AddDocument(db, new Document("doc1").Set("t1", "hello").Set("t2", "world"));
226+
Assert.Equal(1, DatabaseSize(db)); // in part, this is to allow replication to catch up
226227

227228
// load t1
228229
var req = new AggregationRequest("*").Load(new FieldName("t1"));
229230
var res = ft.Aggregate("idx", req);
231+
Assert.NotNull(res[0]?["t1"]);
230232
Assert.Equal("hello", res[0]!["t1"].ToString());
231233

232234
// load t2
233235
req = new AggregationRequest("*").Load(new FieldName("t2"));
234236
res = ft.Aggregate("idx", req);
237+
Assert.NotNull(res[0]?["t2"]);
235238
Assert.Equal("world", res[0]!["t2"]);
236239

237240
// load all
238241
req = new AggregationRequest("*").LoadAll();
239242
res = ft.Aggregate("idx", req);
243+
Assert.NotNull(res[0]?["t1"]);
240244
Assert.Equal("hello", res[0]!["t1"].ToString());
245+
Assert.NotNull(res[0]?["t2"]);
241246
Assert.Equal("world", res[0]!["t2"]);
242247
}
243248

@@ -251,26 +256,29 @@ public async Task TestAggregationsLoadAsync(string endpointId)
251256
await ft.CreateAsync("idx", new(), sc);
252257

253258
AddDocument(db, new Document("doc1").Set("t1", "hello").Set("t2", "world"));
259+
Assert.Equal(1, await DatabaseSizeAsync(db)); // in part, this is to allow replication to catch up
254260

255261
// load t1
256262
var req = new AggregationRequest("*").Load(new FieldName("t1"));
257263
var res = await ft.AggregateAsync("idx", req);
264+
Assert.NotNull(res[0]?["t1"]);
258265
Assert.Equal("hello", res[0]!["t1"].ToString());
259266

260267
// load t2
261268
req = new AggregationRequest("*").Load(new FieldName("t2"));
262269
res = await ft.AggregateAsync("idx", req);
270+
Assert.NotNull(res[0]?["t2"]);
263271
Assert.Equal("world", res[0]!["t2"]);
264272

265273
// load all
266274
req = new AggregationRequest("*").LoadAll();
267275
res = await ft.AggregateAsync("idx", req);
276+
Assert.NotNull(res[0]?["t1"]);
268277
Assert.Equal("hello", res[0]!["t1"].ToString());
278+
Assert.NotNull(res[0]?["t2"]);
269279
Assert.Equal("world", res[0]!["t2"]);
270280
}
271281

272-
273-
274282
[SkippableTheory]
275283
[MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))]
276284
public void TestAggregationRequestParamsDialect(string endpointId)
@@ -418,7 +426,16 @@ public void TestAlias(string endpointId)
418426
doc.Add("field1", "value");
419427
AddDocument(db, "doc1", doc);
420428

421-
Assert.True(ft.AliasAdd("ALIAS1", index));
429+
try
430+
{
431+
Assert.True(ft.AliasAdd("ALIAS1", index));
432+
}
433+
catch (RedisServerException rse)
434+
{
435+
Skip.If(rse.Message.StartsWith("CROSSSLOT"), "legacy failure");
436+
throw;
437+
}
438+
422439
SearchResult res1 = ft.Search("ALIAS1", new Query("*").ReturnFields("field1"));
423440
Assert.Equal(1, res1.TotalResults);
424441
Assert.Equal("value", res1.Documents[0]["field1"]);
@@ -447,7 +464,16 @@ public async Task TestAliasAsync(string endpointId)
447464
doc.Add("field1", "value");
448465
AddDocument(db, "doc1", doc);
449466

450-
Assert.True(await ft.AliasAddAsync("ALIAS1", index));
467+
try
468+
{
469+
Assert.True(await ft.AliasAddAsync("ALIAS1", index));
470+
}
471+
catch (RedisServerException rse)
472+
{
473+
Skip.If(rse.Message.StartsWith("CROSSSLOT"), "legacy failure");
474+
throw;
475+
}
476+
451477
SearchResult res1 = ft.Search("ALIAS1", new Query("*").ReturnFields("field1"));
452478
Assert.Equal(1, res1.TotalResults);
453479
Assert.Equal("value", res1.Documents[0]["field1"]);
@@ -642,6 +668,7 @@ public void CreateWithFieldNames(string endpointId)
642668
db.HashSet("pupil:4444", [new("first", "Pat"), new("last", "Shu"), new("age", "21")]);
643669
db.HashSet("student:5555", [new("first", "Joen"), new("last", "Ko"), new("age", "20")]);
644670
db.HashSet("teacher:6666", [new("first", "Pat"), new("last", "Rod"), new("age", "20")]);
671+
Assert.Equal(7, DatabaseSize(db)); // in part, this is to allow replication to catch up
645672

646673
SearchResult noFilters = ft.Search(index, new());
647674
Assert.Equal(5, noFilters.TotalResults);
@@ -3631,7 +3658,7 @@ public void TestDocumentLoad_Issue352()
36313658
/// https://redis.io/docs/latest/commands/ft.search/#:~:text=If%20a%20relevant%20key%20expires,the%20total%20number%20of%20results.
36323659
/// </summary>
36333660
[SkippableTheory]
3634-
[MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))]
3661+
[MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))]
36353662
public async Task TestDocumentLoadWithDB_Issue352(string endpointId)
36363663
{
36373664
IDatabase db = GetCleanDatabase(endpointId);

0 commit comments

Comments
 (0)