Skip to content

Commit

Permalink
fix(driver): enable tests for select iter (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
everpcpc authored Apr 14, 2023
1 parent fe60d1a commit 22695e7
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 88 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ build:
test:
cargo test --all --all-features --lib -- --nocapture

integration-down:
make -C tests down

integration-tests:
make -C tests

Expand Down
165 changes: 77 additions & 88 deletions driver/tests/driver/select_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,94 +24,83 @@ async fn prepare(name: &str) -> (Box<dyn Connection>, 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<RowResult> = 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<RowResult> = 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() {
Expand Down

0 comments on commit 22695e7

Please sign in to comment.