Skip to content

Commit

Permalink
Add idempotency to tests and update tests to check more edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
jhiemstrawisc committed Feb 21, 2024
1 parent f420248 commit 17ce2ba
Show file tree
Hide file tree
Showing 2 changed files with 201 additions and 76 deletions.
18 changes: 18 additions & 0 deletions src/lotman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1460,13 +1460,31 @@ int lotman_list_all_lots(char ***output, char **err_msg) {
}


// Given a lot_name and a recursive flag, generate the lot's information and return it as JSON. Recursive in this case
// indicates that we want to look up/down the tree of lots to determine the most restrictive values associated with parents/children.
int lotman_get_lot_as_json(const char *lot_name, const bool recursive, char **output, char **err_msg) {
try {
if (!lot_name) {
if (err_msg) {*err_msg = strdup("Name for the lot to be returned as JSON must not be nullpointer.");}
return -1;
}

// Check for existence of the lot we're asking about
auto rp = lotman::Lot::lot_exists(lot_name);
if (!rp.first) {
if (err_msg) {
if (rp.second.empty()) { // function worked, but lot does not exist
*err_msg = strdup("That was easy! The lot does not exist, so there's nothing to return.");
}
else {
std::string int_err = rp.second;
std::string ext_err = "Function call to lotman::Lot::lot_exists failed: ";
*err_msg = strdup((ext_err + int_err).c_str());
}
return -1;
}
}

auto rp_bool_str = lotman::Lot::update_db_children_usage();
if (!rp_bool_str.first) {
if (err_msg) {
Expand Down
Loading

0 comments on commit 17ce2ba

Please sign in to comment.