@@ -248,10 +248,11 @@ std::ostream &operator<<(std::ostream &out, const Item &item)
248248
249249struct http_result {
250250 lcb_STATUS rc{LCB_SUCCESS};
251- uint16_t status{0 };
251+ std:: uint16_t status{0 };
252252 std::string path{};
253253 std::string body{};
254254 std::map<std::string, std::string> headers{};
255+ std::uint16_t expected_status{200 };
255256};
256257
257258struct manifest_result {
@@ -290,7 +291,9 @@ static void http_callback(lcb_INSTANCE * /* instance */, int /* cbtype */, const
290291 }
291292 }
292293
293- EXPECT_EQ (200 , result->status ) << result->path << " : " << result->body ;
294+ if (result->expected_status > 0 ) {
295+ EXPECT_EQ (result->expected_status , result->status ) << result->path << " : " << result->body ;
296+ }
294297}
295298
296299static void get_manifest_callback (lcb_INSTANCE *, int , const lcb_RESPGETMANIFEST *resp)
@@ -348,7 +351,7 @@ static void wait_for_manifest_uid(lcb_INSTANCE *instance, std::uint64_t uid)
348351
349352void create_scope (lcb_INSTANCE *instance, const std::string &scope, bool wait)
350353{
351- ( void ) lcb_install_callback (instance, LCB_CALLBACK_HTTP, (lcb_RESPCALLBACK)http_callback);
354+ auto *old_http_callback = lcb_install_callback (instance, LCB_CALLBACK_HTTP, (lcb_RESPCALLBACK)http_callback);
352355
353356 lcb_CMDHTTP *cmd;
354357 std::string path = " /pools/default/buckets/" + MockEnvironment::getInstance ()->getBucket () + " /scopes" ;
@@ -374,11 +377,12 @@ void create_scope(lcb_INSTANCE *instance, const std::string &scope, bool wait)
374377 if (wait) {
375378 wait_for_manifest_uid (instance, uid);
376379 }
380+ (void )lcb_install_callback (instance, LCB_CALLBACK_HTTP, (lcb_RESPCALLBACK)old_http_callback);
377381}
378382
379383void create_collection (lcb_INSTANCE *instance, const std::string &scope, const std::string &collection, bool wait)
380384{
381- ( void ) lcb_install_callback (instance, LCB_CALLBACK_HTTP, (lcb_RESPCALLBACK)http_callback);
385+ auto *old_http_callback = lcb_install_callback (instance, LCB_CALLBACK_HTTP, (lcb_RESPCALLBACK)http_callback);
382386
383387 lcb_CMDHTTP *cmd;
384388 std::string path =
@@ -406,11 +410,12 @@ void create_collection(lcb_INSTANCE *instance, const std::string &scope, const s
406410 if (wait) {
407411 wait_for_manifest_uid (instance, uid);
408412 }
413+ (void )lcb_install_callback (instance, LCB_CALLBACK_HTTP, (lcb_RESPCALLBACK)old_http_callback);
409414}
410415
411416void drop_scope (lcb_INSTANCE *instance, const std::string &scope, bool wait)
412417{
413- ( void ) lcb_install_callback (instance, LCB_CALLBACK_HTTP, (lcb_RESPCALLBACK)http_callback);
418+ auto *old_http_callback = lcb_install_callback (instance, LCB_CALLBACK_HTTP, (lcb_RESPCALLBACK)http_callback);
414419
415420 lcb_CMDHTTP *cmd;
416421 std::string path = " /pools/default/buckets/default/scopes/" + scope;
@@ -433,11 +438,12 @@ void drop_scope(lcb_INSTANCE *instance, const std::string &scope, bool wait)
433438 if (wait) {
434439 wait_for_manifest_uid (instance, uid);
435440 }
441+ (void )lcb_install_callback (instance, LCB_CALLBACK_HTTP, (lcb_RESPCALLBACK)old_http_callback);
436442}
437443
438444void drop_collection (lcb_INSTANCE *instance, const std::string &scope, const std::string &collection, bool wait)
439445{
440- ( void ) lcb_install_callback (instance, LCB_CALLBACK_HTTP, (lcb_RESPCALLBACK)http_callback);
446+ auto *old_http_callback = lcb_install_callback (instance, LCB_CALLBACK_HTTP, (lcb_RESPCALLBACK)http_callback);
441447
442448 lcb_CMDHTTP *cmd;
443449 std::string path = " /pools/default/buckets/default/scopes/" + scope + " /collections/" + collection;
@@ -460,6 +466,7 @@ void drop_collection(lcb_INSTANCE *instance, const std::string &scope, const std
460466 if (wait) {
461467 wait_for_manifest_uid (instance, uid);
462468 }
469+ (void )lcb_install_callback (instance, LCB_CALLBACK_HTTP, (lcb_RESPCALLBACK)old_http_callback);
463470}
464471
465472std::string unique_name (const std::string &prefix)
0 commit comments