alamb commented on code in PR #3402:
URL: https://github.com/apache/arrow-rs/pull/3402#discussion_r1062525427


##########
arrow-flight/tests/client.rs:
##########
@@ -259,6 +232,248 @@ async fn test_do_get_error_in_record_batch_stream() {
     .await;
 }
 
+#[tokio::test]
+async fn test_do_put() {
+    do_test(|test_server, mut client| async move {
+        client.add_header("foo", "bar").unwrap();
+
+        // encode the batch as a stream of FlightData
+        let input_flight_data = test_flight_data().await;
+
+        let expected_response = vec![
+            PutResult {
+                app_metadata: Bytes::from("foo"),
+            },
+            PutResult {
+                app_metadata: Bytes::from("bar"),
+            },
+        ];
+
+        test_server
+            
.set_do_put_response(expected_response.clone().into_iter().map(Ok).collect());
+
+        let response_stream = client
+            .do_put(futures::stream::iter(input_flight_data.clone()))
+            .await
+            .expect("error making request");
+
+        let response: Vec<_> = response_stream
+            .try_collect()
+            .await
+            .expect("Error streaming data");
+
+        assert_eq!(response, expected_response);
+        assert_eq!(test_server.take_do_put_request(), Some(input_flight_data));
+        ensure_metadata(&client, &test_server);
+    })
+    .await;
+}
+
+#[tokio::test]
+async fn test_do_put_error() {
+    do_test(|test_server, mut client| async move {
+        client.add_header("foo", "bar").unwrap();
+
+        let input_flight_data = test_flight_data().await;
+
+        let response = client
+            .do_put(futures::stream::iter(input_flight_data.clone()))
+            .await;
+        let response = match response {
+            Ok(_) => panic!("unexpected success"),
+            Err(e) => e,
+        };
+
+        let e = Status::internal("No do_put response configured");
+        expect_status(response, e);
+        // server still got the request
+        assert_eq!(test_server.take_do_put_request(), Some(input_flight_data));
+        ensure_metadata(&client, &test_server);
+    })
+    .await;
+}
+
+#[tokio::test]
+async fn test_do_put_error_stream() {
+    do_test(|test_server, mut client| async move {
+        client.add_header("foo", "bar").unwrap();
+
+        let input_flight_data = test_flight_data().await;
+
+        let response = vec![
+            Ok(PutResult {
+                app_metadata: Bytes::from("foo"),
+            }),
+            Err(FlightError::Tonic(Status::invalid_argument("bad arg"))),
+        ];
+
+        test_server.set_do_put_response(response);
+
+        let response_stream = client
+            .do_put(futures::stream::iter(input_flight_data.clone()))
+            .await
+            .expect("error making request");
+
+        let response: Result<Vec<_>, _> = response_stream.try_collect().await;

Review Comment:
   I tried putzing with this -- the issue is not that FlightError is not 
`Debug` it is that `BoxStream` is not.
   
   Here is the error when I used `unwrap_err()`:
   
   ```
   279  |           let response = client
        |  ________________________^
   280  | |             
.do_put(futures::stream::iter(input_flight_data.clone()))
   281  | |             .await
        | |__________________^ `dyn Stream<Item = 
std::result::Result<PutResult, FlightError>> + std::marker::Send` cannot be 
formatted using `{:?}` because it doesn't implement `Debug`
   282  |               .unwrap_err();
        |                ---------- required by a bound introduced by this call
        |
        = help: the trait `Debug` is not implemented for `dyn Stream<Item = 
std::result::Result<PutResult, FlightError>> + std::marker::Send`
        = help: the following other types implement trait `Debug`:
                  (dyn Any + 'static)
                  (dyn Any + Sync + std::marker::Send + 'static)
                  (dyn Any + std::marker::Send + 'static)
                  (dyn tracing_core::field::Value + 'static)
        = note: required for `Box<dyn Stream<Item = 
std::result::Result<PutResult, FlightError>> + std::marker::Send>` to implement 
`Debug`
        = note: 1 redundant requirement hidden
        = note: required for `Pin<Box<dyn Stream<Item = 
std::result::Result<PutResult, FlightError>> + std::marker::Send>>` to 
implement `Debug`
   
   ```
   
   I tried putzing with the types some but I could not get the traits to be 
happy
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to