Files
cproof/tests/unittests/command/test_cmd_disconnect.c
Michael Vetter e81435be06 tests: standardize naming convention
Use a behavior-driven naming convention for unit tests.

Functions are now named using the pattern: [unit]__[verb]__[scenario]
The __ works as a semantic separator.

Examples:
* jid_create__returns__null_from_null()
* cmd_connect__shows__usage_when_no_server_value

Benefits:
* Easy to find all tests associated with a specific function using the
  mandatory prefix.
* Test output in CI now explicitly describes the unit, the expected
  outcome, and the scenario being tested.

Also disabled keyhandlers tests due to missing code in src/ui.
2026-02-28 12:41:33 +01:00

35 lines
927 B
C

#include "prof_cmocka.h"
#include <stdlib.h>
#include <string.h>
#include "xmpp/chat_session.h"
#include "command/cmd_funcs.h"
#include "xmpp/xmpp.h"
#include "xmpp/roster_list.h"
#include "ui/stub_ui.h"
#define CMD_DISCONNECT "/disconnect"
void
cmd_disconnect__updates__clears_chat_sessions(void** state)
{
chat_sessions_init();
roster_create();
chat_session_recipient_active("bob@server.org", "laptop", FALSE);
chat_session_recipient_active("mike@server.org", "work", FALSE);
will_return(connection_get_status, JABBER_CONNECTED);
will_return(connection_get_barejid, "myjid@myserver.com");
expect_any_cons_show();
gboolean result = cmd_disconnect(NULL, CMD_DISCONNECT, NULL);
assert_true(result);
ChatSession* session1 = chat_session_get("bob@server.org");
ChatSession* session2 = chat_session_get("mike@server.org");
assert_null(session1);
assert_null(session2);
}