Open Source alternative to Algolia + Pinecone and an Easier-to-Use alternative to ElasticSearch ⚡ 🔍 ✨ Fast, typo tolerant, in-memory fuzzy Search Engine for building delightful search experiences
C++ algoliadatastoreelasticsearchenterprise-searchfacetingfull-text-searchfuzzy-searchgeosearchin-memoryinstantsearchmerchandisingpineconesearchsearch-enginesemantic-searchsimilarity-searchsite-searchsynonymstypo-tolerancevector-search
When key not found during deletion, return 404 and not 500.
Kishore Nallana0da8929cd27
diff --git a/src/auth_manager.cpp b/src/auth_manager.cppindex 4c93fb4a..8dae99ad 100644--- a/src/auth_manager.cpp+++ b/src/auth_manager.cpp@@ -117,7 +117,7 @@ Option<api_key_t> AuthManager::remove_key(uint32_t id) {Option<api_key_t> key_op = get_key(id, false);if(!key_op.ok()) {- return Option<api_key_t>(500, key_op.error());+ return Option<api_key_t>(key_op.code(), key_op.error());}std::string api_key_store_key = std::string(API_KEYS_PREFIX) + "_" + std::to_string(id);diff --git a/test/auth_manager_test.cpp b/test/auth_manager_test.cppindex 4423fea2..95bb71fc 100644--- a/test/auth_manager_test.cpp+++ b/test/auth_manager_test.cpp@@ -88,6 +88,14 @@ TEST_F(AuthManagerTest, CreateListDeleteAPIKeys) {ASSERT_EQ("abcd", list_op.get()[0].value);ASSERT_EQ("test key 2", list_op.get()[1].description);ASSERT_EQ("abcd", list_op.get()[1].value);++ // delete key+ auto del_op = auth_manager.remove_key(1);+ ASSERT_TRUE(del_op.ok());++ del_op = auth_manager.remove_key(1000);+ ASSERT_FALSE(del_op.ok());+ ASSERT_EQ(404, del_op.code());}TEST_F(AuthManagerTest, CheckRestoreOfAPIKeys) {