Skip to content

Commit

Permalink
Add more etag edge case tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hamdaankhalidmsft committed Oct 1, 2024
1 parent 98e4ec3 commit da48417
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/Garnet.test/RespEtagTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,35 @@ public void SingleRenameShouldNotAddEtagEvenIfExistingKeyHadEtagButNotTheOrigina
ClassicAssert.AreEqual(null, origValue);
}

[Test]
public void SingleRenameShouldAddEtagIfOldKeyHadEtagButNotExistingNewkey()
{
using var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig());
var db = redis.GetDatabase(0);

string existingNewKey = "key2";
string existingVal = "foo";

ClassicAssert.IsTrue(db.StringSet(existingNewKey, existingVal));

string origValue = "test1";
long etag = (long)db.Execute("SETWITHETAG", ["key1", origValue]);
ClassicAssert.AreEqual(0, etag);

db.KeyRename("key1", existingNewKey);
string retValue = db.StringGet(existingNewKey);
ClassicAssert.AreEqual(origValue, retValue);

// new Key value pair created with older value, the etag is reusing the existingnewkey etag
var res = (RedisResult[])db.Execute("GETWITHETAG", [existingNewKey]);
ClassicAssert.AreEqual(0, (long)res[0]);
ClassicAssert.AreEqual(origValue, res[1].ToString());

origValue = db.StringGet("key1");
ClassicAssert.AreEqual(null, origValue);
}


[Test]
public void PersistTTLTestForEtagSetData()
{
Expand Down

0 comments on commit da48417

Please sign in to comment.