Example #1
0
request_t *
mock_server_receives_query (mock_server_t *server,
                            const char *ns,
                            mongoc_query_flags_t flags,
                            uint32_t skip,
                            uint32_t n_return,
                            const char *query_json,
                            const char *fields_json)
{
   sync_queue_t *q;
   request_t *request;

   q = mock_server_get_queue (server);
   request = (request_t *) q_get (q, server->request_timeout_msec);

   if (request && !request_matches_query (request,
                                          ns,
                                          flags,
                                          skip,
                                          n_return,
                                          query_json,
                                          fields_json,
                                          false)) {
      request_destroy (request);
      return NULL;
   }

   return request;
}
Example #2
0
request_t *
mock_server_receives_query (mock_server_t *server,
                            const char *ns,
                            mongoc_query_flags_t flags,
                            uint32_t skip,
                            uint32_t n_return,
                            const char *query_json,
                            const char *fields_json)
{
   request_t *request;

   request = mock_server_receives_request (server);

   if (request && !request_matches_query (request,
                                          ns,
                                          flags,
                                          skip,
                                          n_return,
                                          query_json,
                                          fields_json,
                                          false)) {
      request_destroy (request);
      return NULL;
   }

   return request;
}
Example #3
0
request_t *
mock_server_receives_command (mock_server_t *server,
                              const char *database_name,
                              mongoc_query_flags_t flags,
                              const char *command_json,
                              ...)
{
   va_list args;
   char *formatted_command_json = NULL;
   char *ns;
   sync_queue_t *q;
   request_t *request;

   va_start (args, command_json);
   if (command_json) {
      formatted_command_json = bson_strdupv_printf (command_json, args);
   }
   va_end (args);

   ns = bson_strdup_printf ("%s.$cmd", database_name);

   q = mock_server_get_queue (server);
   request = (request_t *) q_get (q, server->request_timeout_msec);

   if (request && !request_matches_query (request,
                                          ns,
                                          flags,
                                          0,
                                          1,
                                          formatted_command_json,
                                          NULL,
                                          true)) {
      request_destroy (request);
      request = NULL;
   }

   bson_free (formatted_command_json);
   bson_free (ns);

   return request;
}