Use id handler for software version requests, handle errors

This commit is contained in:
James Booth
2015-08-05 00:26:29 +01:00
parent de747e3d46
commit 2a92169351
7 changed files with 78 additions and 7 deletions

View File

@@ -79,6 +79,7 @@ int main(int argc, char* argv[]) {
PROF_FUNC_TEST(send_software_version_request),
PROF_FUNC_TEST(display_software_version_result),
PROF_FUNC_TEST(shows_message_when_software_version_error),
};
return run_tests(all_tests);

View File

@@ -57,3 +57,28 @@ display_software_version_result(void **state)
prof_output_exact("Name : Profanity");
prof_output_exact("Version : 0.4.7dev.master.2cb2f83");
}
void
shows_message_when_software_version_error(void **state)
{
prof_connect();
stbbr_send(
"<presence to=\"stabber@localhost\" from=\"buddy1@localhost/mobile\">"
"<priority>10</priority>"
"<status>I'm here</status>"
"</presence>"
);
prof_output_exact("Buddy1 (mobile) is online, \"I'm here\"");
stbbr_for_query("jabber:iq:version",
"<iq id=\"*\" lang=\"en\" type=\"error\" to=\"stabber@localhost/profanity\" from=\"buddy1@localhost/laptop\">"
"<query xmlns=\"jabber:iq:version\"/>"
"<error code=\"503\" type=\"cancel\">"
"<service-unavailable xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\"/>"
"</error>"
"</iq>"
);
prof_input("/software buddy1@localhost/laptop");
prof_output_exact("Could not get software version: service-unavailable");
}

View File

@@ -1,3 +1,4 @@
void send_software_version_request(void **state);
void display_software_version_result(void **state);
void shows_message_when_software_version_error(void **state);