Skip to content

Commit

Permalink
test: add unit test for check_map_for_dne_only ()
Browse files Browse the repository at this point in the history
Problem: There are no unit tests for check_map_for_dne_only ().

Add some unit tests.
  • Loading branch information
cmoussa1 committed Mar 5, 2024
1 parent 09888eb commit 3352123
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/plugins/test/accounting_test01.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,35 @@ static void test_get_queue_info_invalid_queue ()
}


// ensure false is returned because we have valid flux-accounting data in map
static void test_check_map_dne_false ()
{
bool result = check_map_for_dne_only (users, users_def_bank);

ok (result == false, "valid flux-accounting data has been loaded");
}


// ensure true is returned because no flux-accounting data is loaded
static void test_check_map_dne_true ()
{
users.clear ();
users_def_bank.clear ();

Association tmp_user = {"DNE", 0.5, 5, 0, 7, 0, {}, {}, 0, 1};
add_user_to_map (users, 9999, "DNE", tmp_user);
users_def_bank[9999] = "DNE";

bool result = check_map_for_dne_only (users, users_def_bank);

ok (result == true, "no flux-accounting data has been loaded");
}


int main (int argc, char* argv[])
{
// declare the number of tests that we plan to run
plan (9);
plan (11);

// add users to the test map
initialize_map (users);
Expand All @@ -208,6 +233,9 @@ int main (int argc, char* argv[])
test_get_queue_info_no_queue_specified ();
test_get_queue_info_unknown_queue ();
test_get_queue_info_invalid_queue ();
test_check_map_dne_false ();
test_check_map_dne_true ();

// indicate we are done testing
done_testing ();

Expand Down

0 comments on commit 3352123

Please sign in to comment.