From e8a4336ab8a8cfb85938c6ca611c5ef3f2b6dc03 Mon Sep 17 00:00:00 2001 From: Johannes Schmidt Date: Fri, 29 May 2026 15:59:35 +0200 Subject: [PATCH] Add test-case for `SendFile()` with non-existant paths --- test/remote-httpmessage.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/remote-httpmessage.cpp b/test/remote-httpmessage.cpp index acbe612c7..23e3e0823 100644 --- a/test/remote-httpmessage.cpp +++ b/test/remote-httpmessage.cpp @@ -353,4 +353,19 @@ BOOST_AUTO_TEST_CASE(response_sendfile) BOOST_REQUIRE_EQUAL(ss.str(), parser.get().body()); } +BOOST_AUTO_TEST_CASE(response_sendfile_invalid_path) +{ + auto future = SpawnSynchronizedCoroutine([this](boost::asio::yield_context yc) { + HttpApiResponse response(server); + + response.result(http::status::ok); + BOOST_REQUIRE_THROW(response.SendFile("", yc), std::ios_base::failure); + }); + + auto status = future.wait_for(10s); + if (status != std::future_status::ready) { + BOOST_FAIL("Exception not thrown."); + } +} + BOOST_AUTO_TEST_SUITE_END()