tj.git-extras/tests
Edwin Kofler 18ecffef5e
Some checks failed
ci / lint (push) Has been cancelled
ci / typo (push) Has been cancelled
ci / test (push) Has been cancelled
ci / build (macos-latest) (push) Has been cancelled
ci / build (ubuntu-latest) (push) Has been cancelled
Implement half of tests in Bats (#1187)
* Initial scaffold

* Finish first half of Bats tests

* Add Bats to CI

* Fix CI

* Fix CI

* Fix configuration to set git name and email

* Fix `GIT_CONFIG_{KEY,VALUE}` indexing

* Fix Git config override precedence

* Remove unused and untested function
2025-03-12 18:15:37 +08:00
..
conftest.py feat: add git-continue (#1176) 2024-11-28 16:50:29 +08:00
git-abort.bats Implement half of tests in Bats (#1187) 2025-03-12 18:15:37 +08:00
git-alias.bats Implement half of tests in Bats (#1187) 2025-03-12 18:15:37 +08:00
git-archive-file.bats Implement half of tests in Bats (#1187) 2025-03-12 18:15:37 +08:00
git-authors.bats Implement half of tests in Bats (#1187) 2025-03-12 18:15:37 +08:00
helper.py feat: add ruff linter with ci check (#1182) 2024-11-28 10:30:14 +08:00
poetry.lock fix(ci): use poetry (#1183) 2024-11-29 10:39:42 +08:00
pyproject.toml fix(ci): use poetry (#1183) 2024-11-29 10:39:42 +08:00
README.md feat: add git-continue (#1176) 2024-11-28 16:50:29 +08:00
test_git_abort.py feat: add ruff linter with ci check (#1182) 2024-11-28 10:30:14 +08:00
test_git_alias.py test(git-alias): add its unit test (#1077) 2023-09-27 10:21:35 +08:00
test_git_archive_file.py feat: add ruff linter with ci check (#1182) 2024-11-28 10:30:14 +08:00
test_git_authors.py feat: add ruff linter with ci check (#1182) 2024-11-28 10:30:14 +08:00
test_git_browse.py feat: add ruff linter with ci check (#1182) 2024-11-28 10:30:14 +08:00
test_git_browse_ci.py feat: add ruff linter with ci check (#1182) 2024-11-28 10:30:14 +08:00
test_git_continue.py feat: add git-continue (#1176) 2024-11-28 16:50:29 +08:00
test_util.sh Implement half of tests in Bats (#1187) 2025-03-12 18:15:37 +08:00

Test for git-extras

The git-extras has its own testcases now, and the more is on the way! So let's introduce it.

We choose python to help us to reach to other shore cause python is life saver.

The test part depends on:

  • python >= 3.11
  • poetry >= 1.8.0
  • pytest >= 8.1.2
  • gitpython >= 3.1.43

So the versions are higher than above is recommended.

How to run the tests

  1. Install poetry
  2. Install the dependencies via poetry install
  3. Run poetry run pytest

It is done or go without poetry,

  1. Install python >= 3.11
  2. Install pytest >= 8.1.2
  3. Install gitpython >= 3.1.43
  4. Install testpath >= 0.6.0
  5. Run pytest

The second way maybe blocked the some missing dependencies at someday, so the first one is recommended.

What and how to create a unit test

One command has a unit test, because one git-* command is just do one thing, so we can eat a piece of git-* command in one time.

For example,

  1. The git-alias should have a test suite, so create test_git_alias.py in the directory test
  2. Create a test class TestGitAlias in the test_git_alias.py
  3. Create a test case test_init, and some test fixtures can be used, temp_repo, named_temp_repo etc.
    • temp_repo is module scoped fixture which create a temporary directory and available in the test suite test_git_alias.py.
    • named_temp_repo is just same as temp_repo except the custom directory renaming.
  4. Loop the third step until the 100% coverage of the function of the git-alias

References