# antidote tests

The test suite is [bats](https://github.com/bats-core/bats-core), in `tests/bats/`
(network tests in `tests/bats/real/`). Run it with `just test`, or
`just test-all` to include the real network tests. See
`tests/bats/helpers/common.bash` for the harness and testing styles.

This README doubles as a [clitest](https://github.com/aureliojargas/clitest)
smoke test of the literate format the suite grew from; `tests/run`
still executes it alongside bats.

Support files:

- `tests/functions/` - autoloaded session helpers (`t_setup`,
  `t_teardown`, `t_setup_real`, `bundle_val`, `print_parsed_bundle`,
  `clone_dirs`, `t_unload_antidote`)
- `tests/bin/` - executables tests shell out to (`mock_fzf`, `subenv`,
  `init_fixtures.zsh`); `t_setup` puts this on `$PATH`
- `tests/tmp_home/` - skeleton HOME copied into each isolated test home
- `tests/testdata/` - golden files and fixtures
- `tests/fixtures/` - generated git fixtures (see `t_setup`)

## Setup

A simple setup consists of:

- Remove existing antidote zstyles
- Don't really git things
- Setup antidote

```zsh
source <(zstyle -L ':antidote:*' | awk '{print "zstyle -d",$2}')
function git { echo "$@" }
ANTIDOTE_HOME=$PWD/tests/zdotdir/antidote_home
source ./antidote.zsh
```

But you probably just want to source setup...

```zsh
% source ./tests/__init__.zsh
% t_setup
%
```

## General

`antidote` with no args displays its help:

```zsh
% antidote
antidote - the cure to slow zsh plugin management

usage: antidote [<flags>] <command> [<args> ...]

flags:
  -h, --help            Show context-sensitive help
  -v, --version         Show application version
      --diagnostics     Show antidote and system diagnostics

commands:
  bundle    Clone bundle(s) and generate the static load script
  install   Clone a new bundle and add it to your plugins file
  update    Update antidote and its cloned bundles
  purge     Remove a cloned bundle
  home      Print where antidote is cloning bundles
  list      List cloned bundles
  path      Print the path of a cloned bundle
  snapshot  Save, restore, or list bundle snapshots
  init      Initialize the shell for dynamic bundles
  help      Show documentation
  load      Statically source all bundles from the plugins file
%
```

## Version

The `-v/--version` flag displays the current version:

```zsh
% zstyle ':antidote:test:version' show-sha off
% antidote --version | sed 's/[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*/X.X.X/g'
antidote version X.X.X
%
```

## Teardown

```zsh
% t_teardown
%
```
