๐งช Gittxt Test Suite¶
This page documents the full test suite for Gittxt, including how tests are structured, executed, and maintained across CLI and API components.
๐ Test Directory Structure¶
tests/
โโโ cli/ # CLI unit & integration tests
โ โโโ generate_test_repo.py # Creates edge-case test repos
โ โโโ test_*.py # Scanner, filters, formats, ZIP, reverse tests
โ
โโโ api/ # FastAPI plugin test coverage
โ โโโ generate_test_repo.py
โ โโโ test_endpoints.py
โ
โโโ Makefile # Unified test runner and cleaner
โโโ README.md # Dev guide for tests
โ How to Run Tests¶
Run All Tests¶
make test
Run Only CLI Tests¶
make cli-tests
Run Only API Tests¶
make api-tests
Run a Specific Test¶
pytest tests/cli/test_scanner.py::test_scanner_with_exclude_pattern -v
๐งช What We Test¶
Core CLI¶
test_scanner.py
: filters,.gittxtignore
, size limits, skipped reasonstest_output_formats.py
:.txt
,.json
,.md
rich output validationtest_lite_mode.py
: ensures lite mode strips metadatatest_zip_bundle.py
: verifies contents of generated ZIP archivestest_cli_run.py
: end-to-end CLI subprocess testingtest_cli_filters.py
: interactive CLI filter updates
Reverse Engineering¶
test_reverse_engineer.py
: reconstructs repos from.txt
,.md
,.json
API Plugin¶
test_endpoints.py
: tests/health
,/scan
,/summary
,/download
,/upload
,/cleanup
Utilities¶
test_repo_handler.py
: GitHub repo resolution, subdir supporttest_formatter_sorting.py
: README prioritization in file sortingtest_subcat_utils.py
: sub-category detection (docs
,config
,code
)
๐ Repo Generation for Tests¶
Two scripts generate test repositories with realistic edge cases:
tests/cli/generate_test_repo.py
tests/api/generate_test_repo.py
These include:
- Minified JS files
- Large files over 5MB
- Binary/non-textual content
- .gittxtignore
-excluded paths
- Hidden and extensionless files
- Deeply nested folders
๐งผ Cleaning Up¶
To clean all test-generated content:
make clean
This will remove:
- tests/cli/test_repo/
- tests/cli/cli_test_outputs/
- tests/api/test_repo/
- tests/api/test_repo.zip
๐ก Best Practices¶
- Run
make test
before every PR submission. - Use
--log-level debug
withgittxt scan
to trace test outputs. - Keep
.gittxtignore
scenarios up to date ingenerate_test_repo.py
. - Reverse engineer tests help validate report integrity for
.txt
,.md
,.json
.
Need help writing new tests? Open an issue or ping us in GitHub Discussions.
Happy testing ๐
Back: Contributing