Skip to content

Commit

Permalink
testing: minimal Bats cli testing setup
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarnett committed Aug 27, 2024
1 parent 533eb49 commit db58a5a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.py }}
- name: Fetch Bats submodules
if: "${{ matrix.py == '3.12' }}"
run: git submodule update
- name: Install tox
run: python -m pip install tox-gh>=1.2
- name: Setup test suite
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ universal = true

[tool.ruff]
line-length = 80
extend-exclude = ["tests/cli/"]

[tool.ruff.lint]
# Enable Errors, Warnings, Flakes
Expand Down
14 changes: 14 additions & 0 deletions tests/cli/test.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
setup() {
load 'test_helper/bats-support/load'
load 'test_helper/bats-assert/load'
}

@test "can run" {
run gcalcli
assert_output --regexp '^usage: .*error:.*required: command\b'
}

@test "prints correct help" {
run gcalcli -h
assert_output --regexp 'positional arguments:.*list.*search.*edit.*options:'
}
11 changes: 9 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tox]
requires =
tox>=4
envlist = lint, type, py3{8,9,10,11,12}
envlist = lint, type, py3{8,9,10,11,12}, cli

[testenv]
usedevelop=true
Expand Down Expand Up @@ -31,9 +31,16 @@ deps =
commands =
mypy {posargs:gcalcli}

[testenv:cli]
description = run functional tests using Bats
allowlist_externals =
./tests/cli/bats/bin/bats
commands =
./tests/cli/bats/bin/bats tests/cli/test.bats

[gh]
python =
3.12 = py312, lint, type
3.12 = py312, lint, type, cli
3.11 = py311
3.10 = py310
3.9 = py39
Expand Down

0 comments on commit db58a5a

Please sign in to comment.