Commit e4ef33bd authored by Nick Craver's avatar Nick Craver

Add tests for #729

parent beb9b46f
...@@ -315,6 +315,45 @@ public void HashScanLarge(int pageSize) ...@@ -315,6 +315,45 @@ public void HashScanLarge(int pageSize)
} }
} }
[Fact] // See https://github.com/StackExchange/StackExchange.Redis/issues/729
public void HashScanThresholds()
{
using (var conn = Create(allowAdmin: true))
{
var config = conn.GetServer(conn.GetEndPoints(true)[0]).ConfigGet("hash-max-ziplist-entries").First();
var threshold = int.Parse(config.Value);
RedisKey key = Me();
Assert.False(GotCursors(conn, key, threshold - 1));
Assert.True(GotCursors(conn, key, threshold + 1));
}
}
private bool GotCursors(ConnectionMultiplexer conn, RedisKey key, int count)
{
var db = conn.GetDatabase();
db.KeyDelete(key);
var entries = new HashEntry[count];
for (var i = 0; i < count; i++)
{
entries[i] = new HashEntry("Item:" + i, i);
}
db.HashSet(key, entries);
var found = false;
var response = db.HashScan(key);
var cursor = ((IScanningCursor)response);
foreach (var i in response)
{
if (cursor.Cursor > 0)
{
found = true;
}
}
return found;
}
[Theory] [Theory]
[InlineData(10)] [InlineData(10)]
[InlineData(100)] [InlineData(100)]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment