Skip to content

Commit

Permalink
joinp: add validation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jqnatividad committed Jul 16, 2023
1 parent 0a3b069 commit dcdc42e
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/test_joinp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ macro_rules! joinp_test {
mod $name {
use std::process;

#[allow(unused_imports)]
use super::{make_rows, setup};
use crate::workdir::Workdir;

Expand Down Expand Up @@ -110,6 +111,39 @@ joinp_test!(
}
);

joinp_test!(
joinp_outer_left_validate_none,
|wrk: Workdir, mut cmd: process::Command| {
cmd.arg("--left").args(["--validate", "none"]);
let got: Vec<Vec<String>> = wrk.read_stdout(&mut cmd);
let expected = make_rows(
false,
vec![
svec!["Boston", "MA", "Logan Airport"],
svec!["Boston", "MA", "Boston Garden"],
svec!["New York", "NY", ""],
svec!["San Francisco", "CA", ""],
svec!["Buffalo", "NY", "Ralph Wilson Stadium"],
],
);
assert_eq!(got, expected);
}
);

joinp_test!(
joinp_outer_left_validate_onetomany,
|wrk: Workdir, mut cmd: process::Command| {
cmd.arg("--left").args(["--validate", "onetomany"]);
let got: String = wrk.output_stderr(&mut cmd);
assert_eq!(
got,
"Polars error: ComputeError(ErrString(\"the join keys did not fulfil 1:m \
validation\"))\n"
);
wrk.assert_err(&mut cmd);
}
);

joinp_test!(joinp_full, |wrk: Workdir, mut cmd: process::Command| {
cmd.arg("--full");
let got: Vec<Vec<String>> = wrk.read_stdout(&mut cmd);
Expand Down

0 comments on commit dcdc42e

Please sign in to comment.