ests: fix functional test rooms_query

This commit is contained in:
Michael Vetter
2026-03-05 13:51:28 +01:00
parent fbd31f61a6
commit 897e192544
2 changed files with 9 additions and 8 deletions

View File

@@ -105,7 +105,11 @@ prof_expect(int fd, ...)
return 0;
}
if (g_regex_match(regex, clean_output, 0, &match_info)) {
gint start_pos, end_pos;
g_match_info_fetch_pos(match_info, 0, &start_pos, &end_pos);
g_string_truncate(accumulated_output, 0);
g_match_info_free(match_info);
g_regex_unref(regex);
g_free(clean_output);
@@ -406,11 +410,9 @@ prof_output_exact(const char* text)
int
prof_output_regex(const char* text)
{
gchar* escaped = g_regex_escape_string(text, -1);
gchar* pattern = g_strdup_printf(".*%s", escaped);
gchar* pattern = g_strdup_printf(".*%s", text);
int res = prof_expect(fd, prof_expect_regexp, pattern, 1, prof_expect_end);
g_free(pattern);
g_free(escaped);
return res;
}

View File

@@ -10,8 +10,8 @@
void
rooms_query(void** state)
{
stbbr_for_id("prof_confreq_*",
"<iq id='prof_confreq_*' type='result' to='stabber@localhost/profanity' from='conference.localhost'>"
stbbr_for_query("http://jabber.org/protocol/disco#items",
"<iq id='*' type='result' to='stabber@localhost/profanity' from='conference.localhost'>"
"<query xmlns='http://jabber.org/protocol/disco#items'>"
"<item jid='chatroom@conference.localhost' name='A chat room'/>"
"<item jid='hangout@conference.localhost' name='Another chat room'/>"
@@ -22,11 +22,10 @@ rooms_query(void** state)
prof_input("/rooms service conference.localhost");
assert_true(prof_output_exact("chatroom@conference.localhost (A chat room)"));
assert_true(prof_output_exact("hangout@conference.localhost (Another chat room)"));
assert_true(prof_output_regex("Room list request sent: conference.localhost[\\s\\S]*chatroom@conference.localhost[\\s\\S]*hangout@conference.localhost"));
assert_true(stbbr_last_received(
"<iq id='prof_confreq_*' to='conference.localhost' type='get'>"
"<iq id='*' to='conference.localhost' type='get'>"
"<query xmlns='http://jabber.org/protocol/disco#items'/>"
"</iq>"));
}