From 77487f18151828516bf735b0a161ec8c8c33781f Mon Sep 17 00:00:00 2001 From: Hamdaan Khalid Date: Wed, 25 Sep 2024 17:36:35 +1000 Subject: [PATCH] Update test --- libs/server/Resp/RespCommandsInfo.json | 56 +++++++++++++++++ .../CommandInfoUpdater/SupportedCommand.cs | 4 ++ test/Garnet.test/Resp/ACL/RespCommandTests.cs | 60 +++++++++++++++++++ 3 files changed, 120 insertions(+) diff --git a/libs/server/Resp/RespCommandsInfo.json b/libs/server/Resp/RespCommandsInfo.json index 65204e82058..0c1d9dba7ab 100644 --- a/libs/server/Resp/RespCommandsInfo.json +++ b/libs/server/Resp/RespCommandsInfo.json @@ -1888,6 +1888,20 @@ ], "SubCommands": null }, + { + "Command": "GETIFNOTMATCH", + "Name": "GETIFNOTMATCH", + "IsInternal": false, + "Arity": 2, + "Flags": "NONE", + "FirstKey": 1, + "LastKey": 1, + "Step": 1, + "AclCategories": "Fast, String, Read", + "Tips": null, + "KeySpecifications": null, + "SubCommands": null + }, { "Command": "GETRANGE", "Name": "GETRANGE", @@ -1917,6 +1931,20 @@ ], "SubCommands": null }, + { + "Command": "GETWITHETAG", + "Name": "GETWITHETAG", + "IsInternal": false, + "Arity": 1, + "Flags": "NONE", + "FirstKey": 1, + "LastKey": 1, + "Step": 1, + "AclCategories": "Fast, String, Read", + "Tips": null, + "KeySpecifications": null, + "SubCommands": null + }, { "Command": "HDEL", "Name": "HDEL", @@ -4023,6 +4051,20 @@ ], "SubCommands": null }, + { + "Command": "SETIFMATCH", + "Name": "SETIFMATCH", + "IsInternal": false, + "Arity": 3, + "Flags": "NONE", + "FirstKey": 1, + "LastKey": 1, + "Step": 1, + "AclCategories": "Fast, String, Write", + "Tips": null, + "KeySpecifications": null, + "SubCommands": null + }, { "Command": "SETRANGE", "Name": "SETRANGE", @@ -4052,6 +4094,20 @@ ], "SubCommands": null }, + { + "Command": "SETWITHETAG", + "Name": "SETWITHETAG", + "IsInternal": false, + "Arity": 2, + "Flags": "NONE", + "FirstKey": 1, + "LastKey": 1, + "Step": 1, + "AclCategories": "Fast, String, Write", + "Tips": null, + "KeySpecifications": null, + "SubCommands": null + }, { "Command": "SINTER", "Name": "SINTER", diff --git a/playground/CommandInfoUpdater/SupportedCommand.cs b/playground/CommandInfoUpdater/SupportedCommand.cs index db39c684fd2..040896fac42 100644 --- a/playground/CommandInfoUpdater/SupportedCommand.cs +++ b/playground/CommandInfoUpdater/SupportedCommand.cs @@ -123,7 +123,9 @@ public class SupportedCommand new("GET", RespCommand.GET), new("GETBIT", RespCommand.GETBIT), new("GETDEL", RespCommand.GETDEL), + new("GETIFNOTMATCH", RespCommand.GETIFNOTMATCH), new("GETRANGE", RespCommand.GETRANGE), + new("GETWITHETAG", RespCommand.GETWITHETAG), new("HDEL", RespCommand.HDEL), new("HELLO", RespCommand.HELLO), new("HEXISTS", RespCommand.HEXISTS), @@ -211,7 +213,9 @@ public class SupportedCommand new("SET", RespCommand.SET), new("SETBIT", RespCommand.SETBIT), new("SETEX", RespCommand.SETEX), + new("SETIFMATCH", RespCommand.SETIFMATCH), new("SETRANGE", RespCommand.SETRANGE), + new("SETWITHETAG", RespCommand.SETWITHETAG), new("SISMEMBER", RespCommand.SISMEMBER), new("SLAVEOF", RespCommand.SECONDARYOF), new("SMEMBERS", RespCommand.SMEMBERS), diff --git a/test/Garnet.test/Resp/ACL/RespCommandTests.cs b/test/Garnet.test/Resp/ACL/RespCommandTests.cs index e616dd58889..abbbafd159c 100644 --- a/test/Garnet.test/Resp/ACL/RespCommandTests.cs +++ b/test/Garnet.test/Resp/ACL/RespCommandTests.cs @@ -4554,6 +4554,66 @@ static async Task DoSetKeepTtlXxAsync(GarnetClient client) } } + [Test] + public async Task SetWithEtagACLsAsync() + { + await CheckCommandsAsync( + "SETWITHETAG", + [DoSetWithEtagAsync] + ); + + static async Task DoSetWithEtagAsync(GarnetClient client) + { + long val = await client.ExecuteForLongResultAsync("SETWITHETAG", ["foo", "bar"]); + ClassicAssert.AreEqual(0, val); + } + } + + [Test] + public async Task SetIfMatchACLsAsync() + { + await CheckCommandsAsync( + "SETIFMATCH", + [DoSetIfMatchAsync] + ); + + static async Task DoSetIfMatchAsync(GarnetClient client) + { + var res = await client.ExecuteForStringResultAsync("SETIFMATCH", ["foo", "rizz", "0"]); + ClassicAssert.IsNull(res); + } + } + + [Test] + public async Task GetIfNotMatchACLsAsync() + { + await CheckCommandsAsync( + "GETIFNOTMATCH", + [DoGetIfNotMatchAsync] + ); + + static async Task DoGetIfNotMatchAsync(GarnetClient client) + { + var res = await client.ExecuteForStringResultAsync("GETIFNOTMATCH", ["foo", "0"]); + ClassicAssert.IsNull(res); + } + } + + [Test] + public async Task GetWithEtagACLsAsync() + { + await CheckCommandsAsync( + "GETWITHETAG", + [DoGetWithEtagAsync] + ); + + static async Task DoGetWithEtagAsync(GarnetClient client) + { + var res = await client.ExecuteForStringResultAsync("GETWITHETAG", ["foo"]); + ClassicAssert.IsNull(res); + } + } + [Test] public async Task SetBitACLsAsync() {