Skip to content

Add automated test suite with BATS #2

@linuz90

Description

@linuz90

Why

lwt has no tests. As features grow (aliases, -yolo, agent integration), it's easy to break argument parsing, worktree path logic, or status detection silently.

Proposal

Use bats-core with --shell /bin/zsh so tests run in the same shell lwt uses.

What to test

  • Utility functions: editor resolution, random branch names, .env copying, lockfile detection, merge/dirty/unpushed status detection
  • Argument parsing: every command's flags, options, error cases
  • Worktree operations: correct paths (../.worktrees/<project>/<branch>/), branch creation, auto-naming
  • Dispatch: routing, aliases (a/s/ls/rm/rn), help output
  • Doctor: dependency reporting

What to skip

  • fzf interaction, editor/agent launching, real network calls — all mocked

Isolation

Each test creates a disposable git repo in /tmp. No side effects on real repos.

Structure

test/
  test_helper/
    bats-support/   # submodule
    bats-assert/    # submodule
    common.bash     # shared setup/teardown + mocks
  utils.bats        # start here — pure functions
  dispatch.bats
  add.bats
  list.bats
  remove.bats
  clean.bats
  rename.bats
  doctor.bats

Run

brew install bats-core
bats --shell /bin/zsh test/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions