Skip to content

Commit 183df47

Browse files
committed
more tests
1 parent 20093b2 commit 183df47

1 file changed

Lines changed: 115 additions & 0 deletions

File tree

tpchgen-cli/tests/cli_integration.rs

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,3 +963,118 @@ async fn test_format_tbl_warns_about_subcommand() {
963963
.success()
964964
.stderr(predicates::str::contains("will be removed in v4.0.0"));
965965
}
966+
967+
/// Test that the `csv` subcommand with a custom delimiter produces tab-delimited output
968+
#[test]
969+
fn test_csv_subcommand_custom_delimiter() {
970+
let temp_dir = tempdir().expect("Failed to create temporary directory");
971+
972+
cargo_bin_cmd!("tpchgen-cli")
973+
.arg("csv")
974+
.arg("--delimiter")
975+
.arg("\\t")
976+
.arg("--scale-factor")
977+
.arg("0.001")
978+
.arg("--tables")
979+
.arg("region")
980+
.arg("--output-dir")
981+
.arg(temp_dir.path())
982+
.assert()
983+
.success();
984+
985+
let csv_file = temp_dir.path().join("region.csv");
986+
assert!(csv_file.exists(), "Expected CSV file {:?} to exist", csv_file);
987+
988+
let contents = std::fs::read_to_string(&csv_file).unwrap();
989+
// Region table has 5 rows; each should contain tabs as delimiters
990+
assert!(
991+
contents.contains('\t'),
992+
"Expected tab-delimited output, got:\n{}",
993+
contents
994+
);
995+
// Verify multiple tab-separated fields per line
996+
let first_line = contents.lines().next().unwrap();
997+
let tab_count = first_line.matches('\t').count();
998+
assert!(
999+
tab_count >= 2,
1000+
"Expected at least 2 tabs per line, got {} in: {}",
1001+
tab_count,
1002+
first_line
1003+
);
1004+
}
1005+
1006+
/// Test that the `tbl` subcommand rejects --delimiter
1007+
#[test]
1008+
fn test_tbl_subcommand_rejects_delimiter() {
1009+
let temp_dir = tempdir().expect("Failed to create temporary directory");
1010+
1011+
cargo_bin_cmd!("tpchgen-cli")
1012+
.arg("tbl")
1013+
.arg("--delimiter")
1014+
.arg(",")
1015+
.arg("--scale-factor")
1016+
.arg("0.001")
1017+
.arg("--tables")
1018+
.arg("part")
1019+
.arg("--output-dir")
1020+
.arg(temp_dir.path())
1021+
.assert()
1022+
.failure()
1023+
.stderr(predicates::str::contains("unexpected argument"));
1024+
}
1025+
1026+
/// Test that deprecated --format=parquet with --parquet-compression still works
1027+
#[tokio::test]
1028+
async fn test_deprecated_parquet_compression_flag_works() {
1029+
let output_dir = tempdir().unwrap();
1030+
1031+
cargo_bin_cmd!("tpchgen-cli")
1032+
.arg("--format")
1033+
.arg("parquet")
1034+
.arg("--parquet-compression")
1035+
.arg("ZSTD(1)")
1036+
.arg("--tables")
1037+
.arg("region")
1038+
.arg("--scale-factor")
1039+
.arg("0.001")
1040+
.arg("--output-dir")
1041+
.arg(output_dir.path())
1042+
.assert()
1043+
.success()
1044+
.stderr(predicates::str::contains("--parquet-compression flag is deprecated"));
1045+
1046+
let parquet_file = output_dir.path().join("region.parquet");
1047+
assert!(
1048+
parquet_file.exists(),
1049+
"Expected Parquet file {:?} to exist",
1050+
parquet_file
1051+
);
1052+
}
1053+
1054+
/// Test that deprecated --format=parquet with --parquet-row-group-bytes still works
1055+
#[tokio::test]
1056+
async fn test_deprecated_parquet_row_group_bytes_flag_works() {
1057+
let output_dir = tempdir().unwrap();
1058+
1059+
cargo_bin_cmd!("tpchgen-cli")
1060+
.arg("--format")
1061+
.arg("parquet")
1062+
.arg("--parquet-row-group-bytes")
1063+
.arg("1000000")
1064+
.arg("--tables")
1065+
.arg("region")
1066+
.arg("--scale-factor")
1067+
.arg("0.001")
1068+
.arg("--output-dir")
1069+
.arg(output_dir.path())
1070+
.assert()
1071+
.success()
1072+
.stderr(predicates::str::contains("--parquet-row-group-bytes flag is deprecated"));
1073+
1074+
let parquet_file = output_dir.path().join("region.parquet");
1075+
assert!(
1076+
parquet_file.exists(),
1077+
"Expected Parquet file {:?} to exist",
1078+
parquet_file
1079+
);
1080+
}

0 commit comments

Comments
 (0)