Skip to content

Commit

Permalink
test: Add agrpc::run test with stopped GrpcContext
Browse files Browse the repository at this point in the history
  • Loading branch information
Tradias committed Sep 14, 2024
1 parent 0e56440 commit 1dea29d
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/src/test_run_17.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,30 @@ TEST_CASE_FIXTURE(
agrpc::run_completion_queue(grpc_context, io_context);
CHECK(invoked);
CHECK_FALSE(has_posted);
}

TEST_CASE_FIXTURE(RunTest, "agrpc::run runs io_context even when grpc_context is stopped")
{
bool posted{false};
bool timer_expired{false};
agrpc::Alarm alarm{grpc_context};
asio::post(grpc_context,
[&]
{
posted = true;
});
grpc_context.stop();
asio::steady_timer timer{io_context};
asio::post(io_context,
[&]
{
timer.async_wait(
[&](auto&&...)
{
timer_expired = true;
});
});
agrpc::run(grpc_context, io_context);
CHECK_FALSE(posted);
CHECK(timer_expired);
}

0 comments on commit 1dea29d

Please sign in to comment.