Skip to content

Commit 2b9330f

Browse files
authored
integration test timing issues (#306)
1 parent 7d119b6 commit 2b9330f

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

test/Redis.OM.Unit.Tests/CoreTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ public async Task SimpleHashInsertWhenAsync()
259259
res = await collection.InsertAsync(obj, WhenKey.NotExists, TimeSpan.FromMilliseconds(5000));
260260
Assert.Null(res);
261261
var expiration = (long)await connection.ExecuteAsync("PTTL", key);
262-
Assert.True(expiration < 4000, $"Expiration is {expiration}");
262+
Assert.True(expiration < 4050, $"Expiration is {expiration}");
263263
res = await collection.InsertAsync(obj, WhenKey.Exists, TimeSpan.FromMilliseconds(5000));
264264
Assert.NotNull(res);
265265

@@ -303,7 +303,7 @@ public void SimpleHashInsertWhen()
303303
res = collection.Insert(obj, WhenKey.NotExists, TimeSpan.FromMilliseconds(5000));
304304
Assert.Null(res);
305305
var expiration = (long)connection.Execute("PTTL", key);
306-
Assert.True(expiration < 4000);
306+
Assert.True(expiration <= 4050);
307307
res = collection.Insert(obj, WhenKey.Exists, TimeSpan.FromMilliseconds(5000));
308308
Assert.NotNull(res);
309309

@@ -348,15 +348,15 @@ public async Task SimpleJsonInsertWhenAsync()
348348
res = await collection.InsertAsync(obj, WhenKey.NotExists, TimeSpan.FromMilliseconds(5000));
349349
Assert.Null(res);
350350
var expiration = (long)await connection.ExecuteAsync("PTTL", key);
351-
Assert.True(expiration < 4000);
351+
Assert.True(expiration <= 4050, $"Actual: {expiration}");
352352
res = await collection.InsertAsync(obj, WhenKey.Exists, TimeSpan.FromMilliseconds(5000));
353353
expiration = (long)await connection.ExecuteAsync("PTTL", key);
354354
Assert.NotNull(res);
355-
Assert.True(expiration > 4000);
355+
Assert.True(expiration >= 4000, $"Actual: {expiration}");
356356
res = collection.Insert(obj, WhenKey.Always, TimeSpan.FromMilliseconds(6000));
357357
expiration = (long)connection.Execute("PTTL", key);
358358
Assert.NotNull(res);
359-
Assert.True(expiration>5000);
359+
Assert.True(expiration>=5000);
360360
res = collection.Insert(obj, WhenKey.Always);
361361
expiration = (long)connection.Execute("PTTL", key);
362362
Assert.NotNull(res);
@@ -396,7 +396,7 @@ public void SimpleJsonInsertWhen()
396396
res = collection.Insert(obj, WhenKey.NotExists, TimeSpan.FromMilliseconds(5000));
397397
Assert.Null(res);
398398
var expiration = (long)connection.Execute("PTTL", key);
399-
Assert.True(expiration < 4000, $"Expiration: {expiration}");
399+
Assert.True(expiration <= 4050, $"Expiration: {expiration}");
400400
res = collection.Insert(obj, WhenKey.Exists, TimeSpan.FromMilliseconds(5000));
401401
Assert.NotNull(res);
402402
res = collection.Insert(obj, WhenKey.Always, TimeSpan.FromMilliseconds(6000));

test/Redis.OM.Unit.Tests/RediSearchTests/SearchFunctionalTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,12 @@ public void TestSave()
154154
var count = collection.Count();
155155
foreach (var person in collection)
156156
{
157-
person.Name = "Steve";
157+
person.Name = "TestSave";
158158
person.Mother = new Person {Name = "Diane"};
159159
}
160160

161161
collection.Save();
162-
var steves = collection.Where(x => x.Name == "Steve");
162+
var steves = collection.Where(x => x.Name == "TestSave");
163163
Assert.Equal(count, steves.Count());
164164
}
165165

@@ -171,12 +171,12 @@ public async Task TestSaveAsync()
171171
await foreach (var person in collection.Where(x=>x.Name == "Chris"))
172172
{
173173
count++;
174-
person.Name = "Augustine";
174+
person.Name = "TestSaveAsync";
175175
person.Mother = new Person {Name = "Monica"};
176176
person.IsEngineer = true;
177177
}
178178
await collection.SaveAsync();
179-
var augustines = collection.Where(x => x.Name == "Augustine");
179+
var augustines = collection.Where(x => x.Name == "TestSaveAsync");
180180
var numSteves = augustines.Count();
181181
Assert.Equal(count, augustines.Count());
182182
}
@@ -191,11 +191,11 @@ public async Task TestSaveAsyncSecondEnumeration()
191191
await foreach (var person in collection.Where(x => x.Name == "Chris"))
192192
{
193193
count++;
194-
person.Name = "Thomas";
194+
person.Name = "TestSaveAsyncSecondEnumeration";
195195
}
196196

197197
await collection.SaveAsync();
198-
var augustines = collection.Where(x => x.Name == "Thomas");
198+
var augustines = collection.Where(x => x.Name == "TestSaveAsyncSecondEnumeration");
199199
Assert.Equal(count, augustines.Count());
200200

201201
}
@@ -207,11 +207,11 @@ public async Task TestSaveHashAsync()
207207
var count = collection.Count();
208208
await foreach (var person in collection)
209209
{
210-
person.Name = "Steve";
210+
person.Name = "TestSaveHashAsync";
211211
person.Mother = new HashPerson {Name = "Diane"};
212212
}
213213
await collection.SaveAsync();
214-
var steves = collection.Where(x => x.Name == "Steve");
214+
var steves = collection.Where(x => x.Name == "TestSaveHashAsync");
215215
Assert.Equal(count, steves.Count());
216216
}
217217

test/Redis.OM.Unit.Tests/RediSearchTests/SearchTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ public async Task TestUpdateJsonUnloadedScriptAsync()
794794
var steve = collection.First(x => x.Name == "Steve");
795795
steve.Age = 33;
796796
await collection.UpdateAsync(steve);
797-
_mock.Verify(x => x.ExecuteAsync("EVALSHA", "cbbf1c4fab5064f419e469cc51c563f8bf51e6fb", "1", "Redis.OM.Unit.Tests.RediSearchTests.Person:01FVN836BNQGYMT80V7RCVY73N", "SET", "$.Age", "33"));
797+
_mock.Verify(x => x.ExecuteAsync("EVALSHA", It.IsAny<string>(), "1", "Redis.OM.Unit.Tests.RediSearchTests.Person:01FVN836BNQGYMT80V7RCVY73N", "SET", "$.Age", "33"));
798798
_mock.Verify(x => x.ExecuteAsync("EVAL",Scripts.JsonDiffResolution, "1", "Redis.OM.Unit.Tests.RediSearchTests.Person:01FVN836BNQGYMT80V7RCVY73N", "SET", "$.Age", "33"));
799799
Scripts.ShaCollection.Clear();
800800
}
@@ -865,7 +865,7 @@ public async Task TestUpdateJsonWithDouble()
865865
steve.Age = 33;
866866
steve.Height = 71.5;
867867
await collection.UpdateAsync(steve);
868-
_mock.Verify(x => x.ExecuteAsync("EVALSHA", "42", "1", "Redis.OM.Unit.Tests.RediSearchTests.Person:01FVN836BNQGYMT80V7RCVY73N", "SET", "$.Age", "33", "SET", "$.Height", "71.5"));
868+
_mock.Verify(x => x.ExecuteAsync("EVALSHA", It.IsAny<string>(), "1", "Redis.OM.Unit.Tests.RediSearchTests.Person:01FVN836BNQGYMT80V7RCVY73N", "SET", "$.Age", "33", "SET", "$.Height", "71.5"));
869869
Scripts.ShaCollection.Clear();
870870
}
871871

0 commit comments

Comments
 (0)