-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce pytest with some basic tests for the CLI. We will expand on the testing now that we have it setup. Added it to the workflow for GitHub as well.
- Loading branch information
Showing
7 changed files
with
106 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from sqlelf import cli | ||
import pytest | ||
from io import StringIO | ||
|
||
def test_cli_bad_arguments(): | ||
with pytest.raises(SystemExit): | ||
cli.start(["--does-not-exist"]) | ||
|
||
def test_cli_no_arguments(): | ||
with pytest.raises(SystemExit): | ||
cli.start([]) | ||
|
||
def test_cli_single_file_arguments(): | ||
stdin = StringIO("") | ||
cli.start(["/bin/ls"], stdin) | ||
|
||
def test_cli_prompt_single_file_arguments(): | ||
stdin = StringIO(".exit 56\n") | ||
with pytest.raises(SystemExit) as err: | ||
cli.start(["/bin/ls"], stdin) | ||
assert err.value.code == 56 |