Add subscribe_barrier test
This commit is contained in:
@@ -363,6 +363,34 @@ bool test_getmessages_subscribe(test_state *state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_subscribe_barrier(test_state *state) {
|
||||
cosmo *client = create_client(state);
|
||||
|
||||
json_t *subject = random_subject(NULL, NULL);
|
||||
json_t *message_out = random_message();
|
||||
|
||||
promise *promise_obj = promise_create(NULL, NULL, NULL);
|
||||
cosmo_send_message(client, subject, message_out, promise_obj);
|
||||
assert(promise_wait(promise_obj, NULL));
|
||||
promise_destroy(promise_obj);
|
||||
|
||||
promise_obj = promise_create(NULL, NULL, NULL);
|
||||
cosmo_subscribe(client, subject, -1, 0, promise_obj);
|
||||
assert(promise_wait(promise_obj, NULL));
|
||||
promise_destroy(promise_obj);
|
||||
|
||||
json_t *messages = cosmo_get_messages(client, subject);
|
||||
assert(messages);
|
||||
assert(json_equal(json_object_get(json_array_get(messages, 0), "message"), message_out));
|
||||
json_decref(messages);
|
||||
|
||||
json_decref(message_out);
|
||||
json_decref(subject);
|
||||
|
||||
cosmo_shutdown(client);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_resubscribe(test_state *state) {
|
||||
cosmo *client = create_client(state);
|
||||
|
||||
@@ -395,6 +423,7 @@ int main(int argc, char *argv[]) {
|
||||
RUN_TEST(test_send_message_promise);
|
||||
RUN_TEST(test_subscribe_unsubscribe_promise);
|
||||
RUN_TEST(test_getmessages_subscribe);
|
||||
RUN_TEST(test_subscribe_barrier);
|
||||
RUN_TEST(test_resubscribe);
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user