Skip to content

Commit 40e8332

Browse files
committed
Add tests where command reports errors
1 parent 150222d commit 40e8332

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

e2e/test_lint_requirements.sh

+17-3
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,24 @@ source "$SCRIPTDIR/common.sh"
88

99
pass=true
1010

11-
fromager lint-requirements "$SCRIPTDIR/validate_inputs/constraints.txt" "$SCRIPTDIR/validate_inputs/requirements.txt"
11+
# Test to demonstrate that command works as expected when input files are valid
1212

13-
if [ $? -ne 0 ]; then
14-
echo "the input files are not correctly formatted."
13+
if ! fromager lint-requirements "$SCRIPTDIR/validate_inputs/constraints.txt" "$SCRIPTDIR/validate_inputs/requirements.txt"; then
14+
echo "the input files are not correctly formatted." 1>&2
15+
pass=false
16+
fi;
17+
18+
# Test to demonstrate failing of command due to missing input args
19+
20+
if fromager lint-requirements "$SCRIPTDIR/validate_inputs/constraints.txt"; then
21+
echo "input arguments are missing for the command" 1>&2
22+
pass=false
23+
fi;
24+
25+
# Test to demonstrate that command reports error for invalid / bad input files
26+
27+
if fromager lint-requirements "$SCRIPTDIR/validate_inputs/constraints.txt" "$SCRIPTDIR/validate_inputs/invalid-requirements.txt"; then
28+
echo "input arguments are missing for the command" 1>&2
1529
pass=false
1630
fi;
1731

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# This requirements file is invalid on purpose to test the lint-requirements
2+
# command of fromager. Do not attempt to fix this file
3+
4+
foo==
5+
bar<=

e2e/validate_inputs/requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This requirements.txt is used for testing lint_requirements
2-
# command of fromager an contains examples of packages
2+
# command of fromager and contains examples of packages
33
stevedore==5.2.0
44
kfp==2.11.0
55

0 commit comments

Comments
 (0)