Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions 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;
ccdbUrl = "";
BOOST_CHECK_EXCEPTION(api.init(ccdbUrl), invalid_argument, [](std::invalid_argument const&) -> bool { return true; });
}