Add resubscription after reconnect, with a test.

This commit is contained in:
Ian Gulliver
2015-06-18 04:11:13 +00:00
parent f89e936f55
commit c72f2ff30e
2 changed files with 62 additions and 3 deletions

View File

@@ -142,10 +142,38 @@ bool test_logout_fires(test_state *state) {
return true;
}
bool test_resubscribe(test_state *state) {
cosmo *client = create_client(state);
json_t *subject = random_subject(NULL, NULL);
cosmo_subscribe(client, subject, -1, 0);
json_t *message_out = random_message();
cosmo_send_message(client, subject, message_out);
const json_t *message_in = wait_for_message(state);
assert(json_equal(message_out, json_object_get(message_in, "message")));
json_decref(message_out);
// Reach in and reset the instance ID so we look new.
cosmo_uuid(client->instance_id);
message_out = random_message();
cosmo_send_message(client, subject, message_out);
message_in = wait_for_message(state);
assert(json_equal(message_out, json_object_get(message_in, "message")));
json_decref(message_out);
json_decref(subject);
cosmo_shutdown(client);
return true;
}
int main(int argc, char *argv[]) {
RUN_TEST(test_create_destroy);
RUN_TEST(test_message_round_trip);
RUN_TEST(test_logout_fires);
RUN_TEST(test_resubscribe);
return 0;
}