Skip to content
Open
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
14 changes: 8 additions & 6 deletions include/boost/redis/adapter/detail/adapters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,14 @@ class general_aggregate {
};
break;
default:
result_->value().push_back({
nd.data_type,
nd.aggregate_size,
nd.depth,
std::string{std::cbegin(nd.value), std::cend(nd.value)}
});
if (result_->has_value()) {
(**result_).push_back({
nd.data_type,
nd.aggregate_size,
nd.depth,
std::string{std::cbegin(nd.value), std::cend(nd.value)}
});
}
}
}
};
Expand Down
34 changes: 34 additions & 0 deletions test/test_conn_exec_error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,38 @@ BOOST_AUTO_TEST_CASE(subscriber_wrong_syntax)
BOOST_TEST(c3_called);
}

BOOST_AUTO_TEST_CASE(issue_287_generic_response_error_then_success)
{
// Setup
auto cfg = make_test_config();
request req;
req.push("PING", "hello");
req.push("set", "mykey"); // This command has a missing argument and will cause an error
req.push("get", "mykey"); // This one is okay
generic_response resp;

// I/O objects
net::io_context ioc;
connection conn{ioc};
bool run_finished = false, exec_finished = false;

conn.async_run(cfg, [&](error_code ec) {
BOOST_TEST(ec == net::error::operation_aborted);
run_finished = true;
});

conn.async_exec(req, resp, [&](error_code ec, std::size_t) {
BOOST_TEST(ec == error_code());
exec_finished = true;
conn.cancel();
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Early feedback: when async_exec fails to execute the commands of a request it should complete with an error. I think all adapters work like this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How the hell do tests pass then? lol

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, none of general_aggregate nor general_simple seem to be setting the output error code on failure.


ioc.run_for(test_timeout);

BOOST_TEST(run_finished);
BOOST_TEST(exec_finished);
BOOST_TEST(resp.has_error());
BOOST_TEST(resp.error().diagnostic == "ERR wrong number of arguments for 'set' command");
}

} // namespace