|
15 | 15 | // specific language governing permissions and limitations
|
16 | 16 | // under the License.
|
17 | 17 |
|
| 18 | +use std::fs; |
18 | 19 | use std::process::Command;
|
19 | 20 |
|
20 | 21 | use assert_cmd::prelude::{CommandCargoExt, OutputAssertExt};
|
@@ -54,3 +55,35 @@ fn cli_quick_test<'a>(
|
54 | 55 | cmd.args(args);
|
55 | 56 | cmd.assert().stdout(predicate::eq(expected));
|
56 | 57 | }
|
| 58 | + |
| 59 | +#[rstest] |
| 60 | +#[case::exec_hf_store_test( |
| 61 | + ["--file", "tests/data/hf_store_sql.txt", "--format", "json", "-q"], |
| 62 | + "tests/data/hf_store_expected.jsonl", |
| 63 | +)] |
| 64 | +#[test] |
| 65 | +fn cli_hf_store_test<'a>( |
| 66 | + #[case] args: impl IntoIterator<Item = &'a str>, |
| 67 | + #[case] expected_file: &str, |
| 68 | +) { |
| 69 | + let mut cmd = Command::cargo_bin("datafusion-cli").unwrap(); |
| 70 | + cmd.args(args); |
| 71 | + |
| 72 | + let actual: Vec<serde_json::Value> = serde_json::Deserializer::from_str( |
| 73 | + String::from_utf8(cmd.assert().get_output().stdout.to_vec()) |
| 74 | + .unwrap() |
| 75 | + .as_str(), |
| 76 | + ) |
| 77 | + .into_iter::<serde_json::Value>() |
| 78 | + .collect::<Result<Vec<serde_json::Value>, _>>() |
| 79 | + .unwrap(); |
| 80 | + |
| 81 | + let expected: Vec<serde_json::Value> = serde_json::Deserializer::from_str( |
| 82 | + fs::read_to_string(expected_file).unwrap().as_str(), |
| 83 | + ) |
| 84 | + .into_iter::<serde_json::Value>() |
| 85 | + .collect::<Result<Vec<serde_json::Value>, _>>() |
| 86 | + .unwrap(); |
| 87 | + |
| 88 | + assert_eq!(actual, expected); |
| 89 | +} |
0 commit comments