Skip to content

Commit

Permalink
tests: updated join right-anti and right-semi tests to account for …
Browse files Browse the repository at this point in the history
…swapped headers

also added repro test from bug report
  • Loading branch information
jqnatividad committed Jan 12, 2025
1 parent d27bc6d commit b171e90
Showing 1 changed file with 50 additions and 4 deletions.
54 changes: 50 additions & 4 deletions tests/test_join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ join_test!(
|wrk: Workdir, mut cmd: process::Command, headers: bool| {
cmd.arg("--right-semi");
let got: Vec<Vec<String>> = wrk.read_stdout(&mut cmd);
let expected = make_rows(
let mut expected = make_rows(
headers,
true,
vec![
Expand All @@ -389,6 +389,9 @@ join_test!(
svec!["Buffalo", "Ralph Wilson Stadium"],
],
);
if headers {
expected[0] = svec!["city", "place"];
}
assert_eq!(got, expected);
}
);
Expand All @@ -398,7 +401,7 @@ join_test!(
|wrk: Workdir, mut cmd: process::Command, headers: bool| {
cmd.arg("--right-semi").arg("--ignore-case");
let got: Vec<Vec<String>> = wrk.read_stdout(&mut cmd);
let expected = make_rows(
let mut expected = make_rows(
headers,
true,
vec![
Expand All @@ -408,6 +411,9 @@ join_test!(
svec!["BOSTON", "BOSTON COMMON"],
],
);
if headers {
expected[0] = svec!["city", "place"];
}
assert_eq!(got, expected);
}
);
Expand All @@ -417,14 +423,17 @@ join_test!(
|wrk: Workdir, mut cmd: process::Command, headers: bool| {
cmd.arg("--right-anti");
let got: Vec<Vec<String>> = wrk.read_stdout(&mut cmd);
let expected = make_rows(
let mut expected = make_rows(
headers,
true,
vec![
svec!["Orlando", "Disney World"],
svec!["BOSTON", "BOSTON COMMON"],
],
);
if headers {
expected[0] = svec!["city", "place"];
}
assert_eq!(got, expected);
}
);
Expand All @@ -434,7 +443,10 @@ join_test!(
|wrk: Workdir, mut cmd: process::Command, headers: bool| {
cmd.arg("--right-anti").arg("--ignore-case");
let got: Vec<Vec<String>> = wrk.read_stdout(&mut cmd);
let expected = make_rows(headers, true, vec![svec!["Orlando", "Disney World"]]);
let mut expected = make_rows(headers, true, vec![svec!["Orlando", "Disney World"]]);
if headers {
expected[0] = svec!["city", "place"];
}
assert_eq!(got, expected);
}
);
Expand Down Expand Up @@ -902,3 +914,37 @@ fn join_with_whitespace() {
];
assert_eq!(got, expected);
}

#[test]
fn join_right_semi_header_order_issue_2434() {
let wrk = Workdir::new("join_right_semi_header_order_issue_2434");
wrk.create(
"file1.csv",
vec![
svec!["id", "company_id", "art_no"],
svec!["1", "A1", "1"],
svec!["2", "A2", "2"],
svec!["3", "A3", "3"],
],
);
wrk.create(
"file2.csv",
vec![
svec!["id", "art_no", "company_id"],
svec!["1", "1", "B1"],
svec!["2", "2", "B2"],
svec!["3", "5", "B3"],
],
);

let mut cmd = wrk.command("join");
cmd.args(["--right-semi", "art_no", "file1.csv", "art_no", "file2.csv"]);

let got: Vec<Vec<String>> = wrk.read_stdout(&mut cmd);
let expected = vec![
svec!["id", "art_no", "company_id"],
svec!["1", "1", "B1"],
svec!["2", "2", "B2"],
];
assert_eq!(got, expected);
}

0 comments on commit b171e90

Please sign in to comment.