test(httphandler): req should return as soon as result is exhausted.
@@ -95,6 +95,24 @@ async fn test_simple_sql() -> Result<()> {
Ok(())
}
+#[tokio::test]
+async fn test_return_when_finish() -> Result<()> {
+ let sql = "select * from numbers(1)";
+ let wait_time_secs = 5;
+ let start_time = std::time::Instant::now();
+ let (status, result) = post_sql(sql, wait_time_secs).await?;
+ let duration = start_time.elapsed().as_secs_f64();
+ assert_eq!(status, StatusCode::OK, "{:?}", result);
+ assert_eq!(result.state, ExecuteStateKind::Succeeded, "{:?}", result);
+ // should not wait until wait_time_secs even if there is no more data
+ assert!(
+ duration < 1.0,
+ "duration {} is too large than expect",
+ duration
+ );
+ Ok(())
+}
+
#[tokio::test]
async fn test_bad_sql() -> Result<()> {
let sql = "bad sql";
