Skip to content

feat: add bats test suite with GHA CI#3

Merged
vojtabiberle merged 2 commits intomasterfrom
feat/add-test-suite
Mar 3, 2026
Merged

feat: add bats test suite with GHA CI#3
vojtabiberle merged 2 commits intomasterfrom
feat/add-test-suite

Conversation

@vojtabiberle
Copy link
Copy Markdown
Owner

@vojtabiberle vojtabiberle commented Mar 3, 2026

Summary

  • Add 58 bats tests (23 unit + 35 integration) covering all git-wt commands, config layering, shell wrapper, and edge cases
  • Add GitHub Actions CI workflow running on push/PR to master
  • Add Makefile targets: make test, make test-unit, make test-integration

Test coverage

Area Tests Covers
sanitize_branch 8 slash→dash, case, dots, empty string
version_gt 6 semver comparison, equality
worktree_path_for 3 prefix, no prefix, uppercase
main_dispatch 6 help flags, unknown cmd, global flags
cmd_add 10 create, source branch, dedup, force, remote, setup hooks, conflicts
cmd_rm 5 remove, nonexistent, force, teardown hooks, auto-detect
cmd_cd 3 path output, missing args, nonexistent
cmd_ls 2 main worktree, added worktree
config 7 defaults, layering, custom dir, relative paths, arrays
shell_wrapper 4 function def, ls, add, cd
edge_cases 4 outside repo, dir conflict, uppercase, deep slashes

Source change

  • git-wt:582: __GIT_WT_TESTING source guard to allow unit test sourcing without triggering main()

Test plan

  • make test-unit — 23 tests pass
  • make test-integration — 35 tests pass
  • GHA CI runs green on this PR

Add 58 tests (23 unit + 35 integration) covering all git-wt commands,
configuration layering, shell wrapper, and edge cases using bats-core.

- test/test_helper.bash: shared setup with isolated git repos
- test/unit/: sanitize_branch, version_gt, worktree_path_for, main_dispatch
- test/integration/: cmd_add, cmd_rm, cmd_cd, cmd_ls, config, shell_wrapper, edge_cases
- .github/workflows/test.yml: CI on push/PR to master
- Makefile: test, test-unit, test-integration targets
- git-wt: add __GIT_WT_TESTING source guard for unit test sourcing
The wt() function calls `git wt` which requires git-wt on PATH.
Locally it works because git-wt is already on PATH, but CI needs
it explicitly.
@vojtabiberle vojtabiberle merged commit 3304946 into master Mar 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant