|
11 | 11 |
|
12 | 12 |
|
13 | 13 | namespace NRedisStack.Tests.Search;
|
14 |
| - |
15 | 14 | public class SearchTests : AbstractNRedisStackTest, IDisposable
|
16 | 15 | {
|
17 | 16 | // private readonly string key = "SEARCH_TESTS";
|
@@ -3313,4 +3312,53 @@ public void TestNumericLogicalOperatorsInDialect4()
|
3313 | 3312 | Assert.Equal(1, ft.Search(index, new Query("@version:[123 123] | @id:[456 7890]")).TotalResults);
|
3314 | 3313 | Assert.Equal(1, ft.Search(index, new Query("@version==123 @id==456").Dialect(4)).TotalResults);
|
3315 | 3314 | }
|
| 3315 | + |
| 3316 | + [Fact] |
| 3317 | + public void TestDocumentLoad_Issue352() |
| 3318 | + { |
| 3319 | + Document d = Document.Load("1", 0.5, null, new RedisValue[] { RedisValue.Null }); |
| 3320 | + Assert.Empty(d.GetProperties().ToList()); |
| 3321 | + } |
| 3322 | + |
| 3323 | + [SkipIfRedis(Is.OSSCluster)] |
| 3324 | + public void TestDocumentLoadWithDB_Issue352() |
| 3325 | + { |
| 3326 | + IDatabase db = redisFixture.Redis.GetDatabase(); |
| 3327 | + db.Execute("FLUSHALL"); |
| 3328 | + var ft = db.FT(); |
| 3329 | + |
| 3330 | + Schema sc = new Schema().AddTextField("first", 1.0).AddTextField("last", 1.0).AddNumericField("age"); |
| 3331 | + Assert.True(ft.Create(index, FTCreateParams.CreateParams(), sc)); |
| 3332 | + |
| 3333 | + Document droppedDocument = null; |
| 3334 | + int numberOfAttempts = 0; |
| 3335 | + do |
| 3336 | + { |
| 3337 | + db.HashSet("student:1111", new HashEntry[] { new("first", "Joe"), new("last", "Dod"), new("age", 18) }); |
| 3338 | + |
| 3339 | + Assert.True(db.KeyExpire("student:1111", TimeSpan.FromMilliseconds(500))); |
| 3340 | + |
| 3341 | + Boolean cancelled = false; |
| 3342 | + Task searchTask = Task.Run(() => |
| 3343 | + { |
| 3344 | + for (int i = 0; i < 100000; i++) |
| 3345 | + { |
| 3346 | + SearchResult result = ft.Search(index, new Query()); |
| 3347 | + List<Document> docs = result.Documents; |
| 3348 | + if (docs.Count == 0 || cancelled) |
| 3349 | + { |
| 3350 | + break; |
| 3351 | + } |
| 3352 | + else if (docs[0].GetProperties().ToList().Count == 0) |
| 3353 | + { |
| 3354 | + droppedDocument = docs[0]; |
| 3355 | + } |
| 3356 | + } |
| 3357 | + }); |
| 3358 | + Task.WhenAny(searchTask, Task.Delay(1000)).GetAwaiter().GetResult(); |
| 3359 | + Assert.True(searchTask.IsCompleted); |
| 3360 | + Assert.Null(searchTask.Exception); |
| 3361 | + cancelled = true; |
| 3362 | + } while (droppedDocument == null && numberOfAttempts++ < 3); |
| 3363 | + } |
3316 | 3364 | }
|
0 commit comments