Skip to content

Commit 2228d00

Browse files
authored
Merge pull request #5487 from gchq/5480-Query-CLI-tests
Issue 5480 - DataFusion CLI tests
2 parents 5b16a53 + d5204e7 commit 2228d00

File tree

2 files changed

+143
-0
lines changed

2 files changed

+143
-0
lines changed
File renamed without changes.

rust/apps/tests/query_cli.rs

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
/*
2+
* Copyright 2022-2025 Crown Copyright
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
use assert_cmd::prelude::*;
17+
use color_eyre::eyre::Result;
18+
use predicates::prelude::*; // Used for writing assertions
19+
use std::process::Command; // Run programs
20+
21+
#[test]
22+
fn invalid_region_maxs() -> Result<()> {
23+
let mut cmd = Command::cargo_bin("query")?;
24+
cmd.args([
25+
"/tmp/output.parquet",
26+
"/tmp/input.parquet",
27+
"--row-keys",
28+
"col1",
29+
"--row-keys",
30+
"col2",
31+
"--region-mins",
32+
"a",
33+
"--region-mins",
34+
"a",
35+
"--region-maxs",
36+
"z",
37+
"--query-mins",
38+
"b",
39+
"--query-mins",
40+
"b",
41+
"--query-maxs",
42+
"g",
43+
"--query-maxs",
44+
"g",
45+
]);
46+
cmd.assert().failure().stderr(predicate::str::contains(
47+
"quantity of region maximums != quantity of row key columns",
48+
));
49+
Ok(())
50+
}
51+
52+
#[test]
53+
fn invalid_region_mins() -> Result<()> {
54+
let mut cmd = Command::cargo_bin("query")?;
55+
cmd.args([
56+
"/tmp/output.parquet",
57+
"/tmp/input.parquet",
58+
"--row-keys",
59+
"col1",
60+
"--row-keys",
61+
"col2",
62+
"--region-mins",
63+
"a",
64+
"--region-maxs",
65+
"z",
66+
"--region-maxs",
67+
"z",
68+
"--query-mins",
69+
"b",
70+
"--query-mins",
71+
"b",
72+
"--query-maxs",
73+
"g",
74+
"--query-maxs",
75+
"g",
76+
]);
77+
cmd.assert().failure().stderr(predicate::str::contains(
78+
"quantity of region minimums != quantity of row key columns",
79+
));
80+
Ok(())
81+
}
82+
83+
#[test]
84+
fn invalid_query_mins() -> Result<()> {
85+
let mut cmd = Command::cargo_bin("query")?;
86+
cmd.args([
87+
"/tmp/output.parquet",
88+
"/tmp/input.parquet",
89+
"--row-keys",
90+
"col1",
91+
"--row-keys",
92+
"col2",
93+
"--region-mins",
94+
"a",
95+
"--region-mins",
96+
"a",
97+
"--region-maxs",
98+
"z",
99+
"--region-maxs",
100+
"z",
101+
"--query-mins",
102+
"b",
103+
"--query-maxs",
104+
"g",
105+
"--query-maxs",
106+
"g",
107+
]);
108+
cmd.assert().failure().stderr(predicate::str::contains(
109+
"quantity of query region minimums != quantity of row key columns",
110+
));
111+
Ok(())
112+
}
113+
114+
#[test]
115+
fn invalid_query_maxs() -> Result<()> {
116+
let mut cmd = Command::cargo_bin("query")?;
117+
cmd.args([
118+
"/tmp/output.parquet",
119+
"/tmp/input.parquet",
120+
"--row-keys",
121+
"col1",
122+
"--row-keys",
123+
"col2",
124+
"--region-mins",
125+
"a",
126+
"--region-mins",
127+
"a",
128+
"--region-maxs",
129+
"z",
130+
"--region-maxs",
131+
"z",
132+
"--query-mins",
133+
"b",
134+
"--query-mins",
135+
"b",
136+
"--query-maxs",
137+
"g",
138+
]);
139+
cmd.assert().failure().stderr(predicate::str::contains(
140+
"quantity of query region maximums != quantity of row key columns",
141+
));
142+
Ok(())
143+
}

0 commit comments

Comments
 (0)