Public Access
IRC: edit server settings as a draft, applied under the service lock
The IRC App edited the live config while the IRC task could be reading it to connect. The App now edits a copy; applyConfig() validates it and swaps it in under the lock, and the task connects from a snapshot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
This commit is contained in:
@@ -64,11 +64,25 @@ void test_autojoin_text_round_trip() {
|
||||
TEST_ASSERT_EQUAL_STRING("#a #b", IrcConfig::formatChannels({"#a", "#b"}).c_str());
|
||||
}
|
||||
|
||||
void test_copy_settings_from_a_draft() {
|
||||
MemoryStore store;
|
||||
IrcConfig live(store);
|
||||
live.load("x");
|
||||
IrcConfig draft = live;
|
||||
draft.host = "irc.example.org";
|
||||
draft.autojoin = {"#a"};
|
||||
TEST_ASSERT_EQUAL_STRING("irc.libera.chat", live.host.c_str()); // the draft is independent
|
||||
live.copySettingsFrom(draft);
|
||||
TEST_ASSERT_EQUAL_STRING("irc.example.org", live.host.c_str());
|
||||
TEST_ASSERT_EQUAL(1, live.autojoin.size());
|
||||
}
|
||||
|
||||
int main() {
|
||||
UNITY_BEGIN();
|
||||
RUN_TEST(test_defaults_point_at_libera_over_tls);
|
||||
RUN_TEST(test_save_and_reload);
|
||||
RUN_TEST(test_invalid_values_are_refused_with_a_reason);
|
||||
RUN_TEST(test_autojoin_text_round_trip);
|
||||
RUN_TEST(test_copy_settings_from_a_draft);
|
||||
return UNITY_END();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user