This is an automated email from the ASF dual-hosted git repository. alamb pushed a commit to branch alamb/rework_format_tests in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git
commit 39a3bb08dca1608cbcd8d7e15cc27938d9ad02bb Author: Andrew Lamb <[email protected]> AuthorDate: Wed Jan 17 07:17:51 2024 -0500 fmt --- datafusion-cli/src/print_format.rs | 51 +++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/datafusion-cli/src/print_format.rs b/datafusion-cli/src/print_format.rs index 5fdc57d617..142f3aae9c 100644 --- a/datafusion-cli/src/print_format.rs +++ b/datafusion-cli/src/print_format.rs @@ -352,35 +352,31 @@ mod tests { Ok(()) } - #[test] fn test_print_batches_empty_batches() -> Result<()> { - let batch = RecordBatch::try_from_iter( - vec![ - ("a", Arc::new(Int32Array::from(vec![1, 2, 3])) as ArrayRef), - ], - )?; + let batch = RecordBatch::try_from_iter(vec![( + "a", + Arc::new(Int32Array::from(vec![1, 2, 3])) as ArrayRef, + )])?; let empty_batch = RecordBatch::new_empty(batch.schema()); + #[rustfmt::skip] + let expected =&[ + "+---+", + "| a |", + "+---+", + "| 1 |", + "| 2 |", + "| 3 |", + "+---+\n", + ]; + PrintBatchesTest::new() .with_format(PrintFormat::Table) - .with_batches(vec![ - empty_batch.clone(), - batch, - empty_batch, - ]) - .with_expected( - &[ - "+---+", - "| a |", - "+---+", - "| 1 |", - "| 2 |", - "| 3 |", - "+---+\n", - ]) + .with_batches(vec![empty_batch.clone(), batch, empty_batch]) + .with_expected(expected) .run(); - Ok(()) + Ok(()) } struct PrintBatchesTest { @@ -398,7 +394,7 @@ mod tests { batches: vec![], maxrows: MaxRows::Unlimited, with_header: false, - expected: vec![] + expected: vec![], } } @@ -423,10 +419,15 @@ mod tests { /// run the test fn run(self) { let mut buffer: Vec<u8> = vec![]; - self.format.print_batches(&mut buffer, &self.batches, self.maxrows, self.with_header).unwrap(); + self.format + .print_batches(&mut buffer, &self.batches, self.maxrows, self.with_header) + .unwrap(); let actual = String::from_utf8(buffer).unwrap(); let expected = self.expected.join("\n"); - assert_eq!(actual, expected, "actual:\n\n{actual}expected:\n\n{expected}"); + assert_eq!( + actual, expected, + "actual:\n\n{actual}expected:\n\n{expected}" + ); } } }
