Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CCDB/src/CcdbApi.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ void CcdbApi::curlInit()

void CcdbApi::init(std::string const& host)
{
if (host.empty()) {
throw std::invalid_argument("Empty url passed CcdbApi, cannot initialize. Aborting.");
}

// if host is prefixed with "file://" this is a local snapshot
// in this case we init the API in snapshot (readonly) mode
constexpr const char* SNAPSHOTPREFIX = "file://";
Expand Down
9 changes: 8 additions & 1 deletion CCDB/test/testCcdbApi.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -589,4 +589,11 @@ BOOST_AUTO_TEST_CASE(vectored)
for (auto context : contexts) {
BOOST_CHECK(context.dest.size() != 0);
}
}
}

BOOST_AUTO_TEST_CASE(empty_url)
{
CcdbApi api;
string url = "";
BOOST_CHECK_EXCEPTION(api.init(url), invalid_argument, [](std::invalid_argument const&) -> bool { return true; });
}