X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=tst%2Fasyncredisstorage_test.cpp;fp=tst%2Fasyncredisstorage_test.cpp;h=f5277a535056d1b1ca3460603f1a4cafc4a976c8;hb=63869e10ac4d8572238989e1b582c0314da91f9c;hp=f526b549fc7700a30d0dcb85408c40319fc0ecb8;hpb=69b0a71f5fe8825fa45ee9502a41fd8b465c44e0;p=ric-plt%2Fsdl.git diff --git a/tst/asyncredisstorage_test.cpp b/tst/asyncredisstorage_test.cpp index f526b54..f5277a5 100644 --- a/tst/asyncredisstorage_test.cpp +++ b/tst/asyncredisstorage_test.cpp @@ -775,6 +775,29 @@ TEST_F(AsyncRedisStorageTest, FindKeysAsyncSuccessfullyAndErrorIsTranslated) savedCommandCb(getWellKnownErrorCode(), replyMock); } +TEST_F(AsyncRedisStorageTest, ListKeysPatternSuccessfullyAndErrorIsTranslated) +{ + InSequence dummy; + expectContentsBuild("KEYS", "{tag1},key[12]"); + expectDispatchAsync(); + sdlStorage->listKeys(ns, + "key[12]", + std::bind(&AsyncRedisStorageTest::findKeysAck, + this, + std::placeholders::_1, + std::placeholders::_2)); + expectGetArray(); + auto expectedDataItem1(Reply::DataItem { key1, ReplyStringLength(key1.size()) }); + auto expectedDataItem2(Reply::DataItem { key2, ReplyStringLength(key2.size()) }); + expectGetDataString(expectedDataItem1); + expectGetType(Reply::Type::NIL); + expectGetDataString(expectedDataItem2); + expectFindKeysAck(std::error_code(), { key1, key2 }); + savedCommandCb(std::error_code(), replyMock); + expectFindKeysAck(getWellKnownErrorCode(), { }); + savedCommandCb(getWellKnownErrorCode(), replyMock); +} + TEST_F(AsyncRedisStorageTest, RemoveAllAsyncSuccessfully) { InSequence dummy; @@ -941,6 +964,26 @@ TEST_F(AsyncRedisStorageTest, RedisSearchPatternCharactersAreCorrectlyEscapedInK ASSERT_STREQ(expectedKeyPrefixSearchPattern.c_str(), builtKeyPrefixSearchPattern.c_str()); } +TEST_F(AsyncRedisStorageTest, BuildNamespaceKeySearchPatternIsCorrect) +{ + InSequence dummy; + const std::string nsPrefix = '{' + ns + '}' + AsyncStorage::SEPARATOR; + std::string buildPattern; + std::string expectedPattern; + + expectedPattern = nsPrefix; + buildPattern = sdlStorage->buildNamespaceKeySearchPattern(ns, ""); + ASSERT_STREQ(expectedPattern.c_str(), buildPattern.c_str()); + + expectedPattern = nsPrefix + '*'; + buildPattern = sdlStorage->buildNamespaceKeySearchPattern(ns, "*"); + ASSERT_STREQ(expectedPattern.c_str(), buildPattern.c_str()); + + expectedPattern = nsPrefix + "h?llo"; + buildPattern = sdlStorage->buildNamespaceKeySearchPattern(ns, "h?llo"); + ASSERT_STREQ(expectedPattern.c_str(), buildPattern.c_str()); +} + TEST_F(AsyncRedisStorageTestDispatcherNotCreated, ReadyAckNotForwardedIfDispatcherNotYetCreated) { InSequence dummy;