Skip to content

Commit

Permalink
🎨 Committing clang-format changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jbbjarnason committed Jun 26, 2024
1 parent 9302e05 commit debb1e4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 22 deletions.
6 changes: 3 additions & 3 deletions exes/themis/inc/alarm_database.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ CREATE TABLE IF NOT EXISTS AlarmVariables(
"INSERT INTO Alarms(tfc_id, sha1sum, alarm_level, alarm_latching, registered_at) VALUES('{}','{}',{}, {}, {}) ON "
"CONFLICT (tfc_id, sha1sum) DO UPDATE SET registered_at={} RETURNING alarm_id;",
tfc_id, sha1_ascii, std::to_underlying(alarm_level), latching ? 1 : 0, ms_count_registered_at,
ms_count_registered_at) >> [&](snitch::api::alarm_id_t id) { alarm_id = id; };
ms_count_registered_at) >>
[&](snitch::api::alarm_id_t id) { alarm_id = id; };
add_alarm_translation(alarm_id, "en", description, details);

// Reset the alarm if high on register
Expand Down Expand Up @@ -258,8 +259,7 @@ ON Alarms.sha1sum = AlarmTranslations.sha1sum;
throw dbus_error("Cannot reset an inactive activation");
}
db_ << fmt::format("UPDATE AlarmActivations SET activation_level = {}, reset_time = {} WHERE activation_id = {};",
std::to_underlying(tfc::snitch::api::state_e::inactive), milliseconds_since_epoch(tp),
activation_id);
std::to_underlying(tfc::snitch::api::state_e::inactive), milliseconds_since_epoch(tp), activation_id);
}
auto set_activation_status(snitch::api::alarm_id_t activation_id, tfc::snitch::api::state_e activation) -> void {
if (!is_activation_high(activation_id)) {
Expand Down
41 changes: 22 additions & 19 deletions exes/themis/tests/themis_database_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,27 +265,30 @@ auto main(int argc, char** argv) -> int {
auto alarms = db.list_alarms();
expect(alarms.size() == 0);
};
"Second time an alarm is registered it should get the correct insert id"_test = []{
auto db = tfc::themis::alarm_database(true);
auto alarm_id = db.register_alarm_en("tfc_id", "description", "details", false, tfc::snitch::level_e::info);
auto alarm_id2 = db.register_alarm_en("tfc_id", "description", "details", false, tfc::snitch::level_e::info);
auto alarms = db.list_alarms();
expect(alarm_id == alarm_id2);
expect(alarms.size() == 1);
expect(alarms.at(0).alarm_id == alarm_id);
};

"Second time an alarm is registered it should get the correct insert id with a different alarm registered in the middle"_test = []{
"Second time an alarm is registered it should get the correct insert id"_test = [] {
auto db = tfc::themis::alarm_database(true);
auto alarm_id_first_time = db.register_alarm_en("tfc_id", "description", "details", false, tfc::snitch::level_e::info);
auto alarm_id = db.register_alarm_en("tfc_id", "description", "details", false, tfc::snitch::level_e::info);
auto alarm_id2 = db.register_alarm_en("tfc_id", "description", "details", false, tfc::snitch::level_e::info);
auto alarms = db.list_alarms();
expect(alarm_id == alarm_id2);
expect(alarms.size() == 1);
auto other_alarm = db.register_alarm_en("tfc_other", "description", "details", false, tfc::snitch::level_e::info);
auto alarm_id_second_time = db.register_alarm_en("tfc_id", "description", "details", false, tfc::snitch::level_e::info);
alarms = db.list_alarms();
expect(alarm_id_first_time == alarm_id_second_time);
expect(alarm_id_first_time != other_alarm);
expect(alarms.size() == 2);
expect(alarms.at(0).alarm_id == alarm_id_first_time);
expect(alarms.at(0).alarm_id == alarm_id);
};

"Second time an alarm is registered it should get the correct insert id with a different alarm registered in the middle"_test =
[] {
auto db = tfc::themis::alarm_database(true);
auto alarm_id_first_time =
db.register_alarm_en("tfc_id", "description", "details", false, tfc::snitch::level_e::info);
auto alarms = db.list_alarms();
expect(alarms.size() == 1);
auto other_alarm = db.register_alarm_en("tfc_other", "description", "details", false, tfc::snitch::level_e::info);
auto alarm_id_second_time =
db.register_alarm_en("tfc_id", "description", "details", false, tfc::snitch::level_e::info);
alarms = db.list_alarms();
expect(alarm_id_first_time == alarm_id_second_time);
expect(alarm_id_first_time != other_alarm);
expect(alarms.size() == 2);
expect(alarms.at(0).alarm_id == alarm_id_first_time);
};
}

0 comments on commit debb1e4

Please sign in to comment.