| 1614 | } |
| 1615 | |
| 1616 | void ErrorHandlingTest::TestAsyncGetFlightInfo() { |
| 1617 | if (!supports_async()) { |
| 1618 | GTEST_SKIP() << "Transport does not support async"; |
| 1619 | } |
| 1620 | // Server-side still does all the junk around trying to translate Arrow |
| 1621 | // status codes, so this test is a little indirect |
| 1622 | |
| 1623 | for (const auto code : kStatusCodes) { |
| 1624 | ARROW_SCOPED_TRACE("C++ status code: ", static_cast<int>(code), ": ", |
| 1625 | Status::CodeAsString(code)); |
| 1626 | |
| 1627 | // Just the status code |
| 1628 | { |
| 1629 | auto descr = FlightDescriptor::Path( |
| 1630 | {std::to_string(static_cast<int>(code)), "Expected message"}); |
| 1631 | auto listener = std::make_shared<TransportStatusListener>(); |
| 1632 | |
| 1633 | client_->GetFlightInfoAsync(descr, listener); |
| 1634 | EXPECT_FINISHES(listener->future); |
| 1635 | auto detail = TransportStatusDetail::Unwrap(listener->future.status()); |
| 1636 | ASSERT_TRUE(detail.has_value()); |
| 1637 | |
| 1638 | EXPECT_EQ(detail->get().code(), kTransportStatusCodes.at(code)); |
| 1639 | // Exact equality - should have no extra junk in the message |
| 1640 | EXPECT_EQ(detail->get().message(), "Expected message"); |
| 1641 | } |
| 1642 | |
| 1643 | // Custom status detail |
| 1644 | { |
| 1645 | auto descr = FlightDescriptor::Path( |
| 1646 | {std::to_string(static_cast<int>(code)), "Expected message", ""}); |
| 1647 | auto listener = std::make_shared<TransportStatusListener>(); |
| 1648 | |
| 1649 | client_->GetFlightInfoAsync(descr, listener); |
| 1650 | EXPECT_FINISHES(listener->future); |
| 1651 | auto detail = TransportStatusDetail::Unwrap(listener->future.status()); |
| 1652 | ASSERT_TRUE(detail.has_value()); |
| 1653 | |
| 1654 | EXPECT_EQ(detail->get().code(), kTransportStatusCodes.at(code)); |
| 1655 | // The server-side arrow::Status-to-TransportStatus conversion puts the |
| 1656 | // detail into the main error message. |
| 1657 | EXPECT_EQ(detail->get().message(), |
| 1658 | "Expected message. Detail: Custom status detail"); |
| 1659 | |
| 1660 | std::string_view arrow_code, arrow_message; |
| 1661 | for (const auto& [key, value] : detail->get().details()) { |
| 1662 | if (key == "x-arrow-status") { |
| 1663 | arrow_code = value; |
| 1664 | } else if (key == "x-arrow-status-message-bin") { |
| 1665 | arrow_message = value; |
| 1666 | } |
| 1667 | } |
| 1668 | EXPECT_EQ(arrow_code, std::to_string(static_cast<int>(code))); |
| 1669 | EXPECT_EQ(arrow_message, "Expected message"); |
| 1670 | } |
| 1671 | |
| 1672 | // Flight status detail |
| 1673 | for (const auto flight_code : kFlightStatusCodes) { |
nothing calls this directly
no test coverage detected