From 4a07dcd3ed28335d1cbcbd5d48a6c1776cd4ebc7 Mon Sep 17 00:00:00 2001 From: everpcpc Date: Fri, 14 Apr 2023 20:05:18 +0800 Subject: [PATCH] fix(driver): enable tests for select iter --- Makefile | 3 + driver/tests/driver/select_iter.rs | 165 ++++++++++++++--------------- 2 files changed, 80 insertions(+), 88 deletions(-) diff --git a/Makefile b/Makefile index b565045d..b7ac87c8 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,9 @@ build: test: cargo test --all --all-features --lib -- --nocapture +integration-down: + make -C tests down + integration-tests: make -C tests diff --git a/driver/tests/driver/select_iter.rs b/driver/tests/driver/select_iter.rs index 189c69a9..ba9dbb67 100644 --- a/driver/tests/driver/select_iter.rs +++ b/driver/tests/driver/select_iter.rs @@ -24,94 +24,83 @@ async fn prepare(name: &str) -> (Box, String) { (conn, table) } -// TODO:(everpcpc) tmp disable for https://github.com/jorgecarleitao/arrow2/pull/1446 -// #[tokio::test] -// async fn select_iter() { -// let (mut conn, table) = prepare("select_iter").await; -// let sql_create = format!( -// "CREATE TABLE `{}` ( -// i64 Int64, -// u64 UInt64, -// f64 Float64, -// s String, -// s2 String, -// a16 Array(Int16), -// a8 Array(UInt8), -// d Date, -// t DateTime -// );", -// table -// ); -// conn.exec(&sql_create).await.unwrap(); -// let sql_insert = format!( -// "INSERT INTO `{}` VALUES -// (-1, 1, 1.0, '1', '1', [1], [10], '2011-03-06', '2011-03-06 06:20:00'), -// (-2, 2, 2.0, '2', '2', [2], [20], '2012-05-31', '2012-05-31 11:20:00'), -// (-3, 3, 3.0, '3', '2', [3], [30], '2016-04-04', '2016-04-04 11:30:00')", -// table -// ); -// type RowResult = ( -// i64, -// u64, -// f64, -// String, -// String, -// String, -// String, -// chrono::NaiveDate, -// chrono::NaiveDateTime, -// ); -// let expected: Vec = vec![ -// ( -// -1, -// 1, -// 1.0, -// "1".into(), -// "1".into(), -// "[1]".into(), -// "[10]".into(), -// chrono::NaiveDate::from_ymd_opt(2011, 3, 6).unwrap(), -// chrono::DateTime::parse_from_rfc3339("2011-03-06T06:20:00Z") -// .unwrap() -// .naive_utc(), -// ), -// ( -// -2, -// 2, -// 2.0, -// "2".into(), -// "2".into(), -// "[2]".into(), -// "[20]".into(), -// chrono::NaiveDate::from_ymd_opt(2012, 5, 31).unwrap(), -// chrono::DateTime::parse_from_rfc3339("2012-05-31T11:20:00Z") -// .unwrap() -// .naive_utc(), -// ), -// ( -// -3, -// 3, -// 3.0, -// "3".into(), -// "2".into(), -// "[3]".into(), -// "[30]".into(), -// chrono::NaiveDate::from_ymd_opt(2016, 4, 4).unwrap(), -// chrono::DateTime::parse_from_rfc3339("2016-04-04T11:30:00Z") -// .unwrap() -// .naive_utc(), -// ), -// ]; -// conn.exec(&sql_insert).await.unwrap(); -// let sql_select = format!("SELECT * FROM `{}`", table); -// let mut rows = conn.query_iter(&sql_select).await.unwrap(); -// let mut row_count = 0; -// while let Some(row) = rows.next().await { -// let v: RowResult = row.unwrap().try_into().unwrap(); -// assert_eq!(v, expected[row_count]); -// row_count += 1; -// } -// } +#[tokio::test] +async fn select_iter() { + let (mut conn, table) = prepare("select_iter").await; + let sql_create = format!( + "CREATE TABLE `{}` ( + i64 Int64, + u64 UInt64, + f64 Float64, + s String, + s2 String, + d Date, + t DateTime + );", + table + ); + conn.exec(&sql_create).await.unwrap(); + let sql_insert = format!( + "INSERT INTO `{}` VALUES + (-1, 1, 1.0, '1', '1', '2011-03-06', '2011-03-06 06:20:00'), + (-2, 2, 2.0, '2', '2', '2012-05-31', '2012-05-31 11:20:00'), + (-3, 3, 3.0, '3', '2', '2016-04-04', '2016-04-04 11:30:00')", + table + ); + type RowResult = ( + i64, + u64, + f64, + String, + String, + chrono::NaiveDate, + chrono::NaiveDateTime, + ); + let expected: Vec = vec![ + ( + -1, + 1, + 1.0, + "1".into(), + "1".into(), + chrono::NaiveDate::from_ymd_opt(2011, 3, 6).unwrap(), + chrono::DateTime::parse_from_rfc3339("2011-03-06T06:20:00Z") + .unwrap() + .naive_utc(), + ), + ( + -2, + 2, + 2.0, + "2".into(), + "2".into(), + chrono::NaiveDate::from_ymd_opt(2012, 5, 31).unwrap(), + chrono::DateTime::parse_from_rfc3339("2012-05-31T11:20:00Z") + .unwrap() + .naive_utc(), + ), + ( + -3, + 3, + 3.0, + "3".into(), + "2".into(), + chrono::NaiveDate::from_ymd_opt(2016, 4, 4).unwrap(), + chrono::DateTime::parse_from_rfc3339("2016-04-04T11:30:00Z") + .unwrap() + .naive_utc(), + ), + ]; + conn.exec(&sql_insert).await.unwrap(); + let sql_select = format!("SELECT * FROM `{}`", table); + let mut rows = conn.query_iter(&sql_select).await.unwrap(); + let mut row_count = 0; + while let Some(row) = rows.next().await { + let v: RowResult = row.unwrap().try_into().unwrap(); + assert_eq!(v, expected[row_count]); + row_count += 1; + } +} #[tokio::test] async fn select_numbers() {