Skip to content

Commit

Permalink
to: update tests that use the dir option
Browse files Browse the repository at this point in the history
  • Loading branch information
jqnatividad committed Sep 20, 2023
1 parent a95cb72 commit d7a8b37
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions tests/test_to.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,20 @@ fn to_xlsx_dir() {
svec!["Orlando", "Disney World"],
];

wrk.create("cities.csv", cities.clone());
wrk.create("places.csv", places.clone());
// create a directory to put the csv files in
let csv_dir = wrk.path("csvdir");
std::fs::create_dir(&csv_dir).unwrap();

wrk.create("csvdir/cities.csv", cities.clone());
wrk.create("csvdir/places.csv", places.clone());

let xlsx_file = wrk.path("testxlsx.xlsx").to_string_lossy().to_string();
log::info!("xlsx_file: {}", xlsx_file);

let mut cmd = wrk.command("to");
cmd.arg("xlsx").arg(xlsx_file.clone()).arg(wrk.path(""));
cmd.arg("xlsx")
.arg(xlsx_file.clone())
.arg(wrk.path("csvdir"));

wrk.assert_success(&mut cmd);

Expand Down Expand Up @@ -163,16 +169,20 @@ fn to_datapackage_dir() {
svec!["Orlando", "Disney World"],
];

wrk.create("cities.csv", cities.clone());
wrk.create("places.csv", places.clone());
// create a directory to put the csv files in
let csv_dir = wrk.path("csvdir");
std::fs::create_dir(&csv_dir).unwrap();

wrk.create("csvdir/cities.csv", cities.clone());
wrk.create("csvdir/places.csv", places.clone());

let dp_file = wrk.path("dpdir.json");
let dp_file_filename = dp_file.to_string_lossy().to_string();

let mut cmd = wrk.command("to");
cmd.arg("datapackage")
.arg(dp_file_filename.clone())
.arg(wrk.path(""));
.arg(wrk.path("csvdir"));

let got: String = wrk.stdout(&mut cmd);
let expected: String = r#"Table 'places' (4 rows)
Expand Down Expand Up @@ -228,16 +238,20 @@ fn to_sqlite_dir() {
svec!["Orlando", "Disney World"],
];

wrk.create("cities.csv", cities.clone());
wrk.create("places.csv", places.clone());
// create a directory to put the csv files in
let csv_dir = wrk.path("csvdir");
std::fs::create_dir(&csv_dir).unwrap();

wrk.create("csvdir/cities.csv", cities.clone());
wrk.create("csvdir/places.csv", places.clone());

let sqlite_file = wrk.path("test_to_sqlite.db");
let sqlite_file_filename = sqlite_file.to_string_lossy().to_string();

let mut cmd = wrk.command("to");
cmd.arg("sqlite")
.arg(sqlite_file_filename.clone())
.arg(wrk.path("."));
.arg(wrk.path("csvdir"));

let got: String = wrk.stdout(&mut cmd);
let expected: String = r#"Table 'places' (4 rows)
Expand Down

0 comments on commit d7a8b37

Please sign in to comment.