0
0
mirror of https://github.com/tj/n.git synced 2024-11-22 11:37:26 +01:00
n/test/tests.md

55 lines
1.5 KiB
Markdown
Raw Normal View History

2019-08-04 02:44:17 +02:00
# Tests
2019-05-04 09:45:53 +02:00
2019-08-04 02:44:17 +02:00
Automated tests for `n`.
2019-05-04 09:45:53 +02:00
## Setup
Optional proxy using mitmproxy:
# using homebrew (Mac) to install mitmproxy
brew install mitmproxy
## Running Tests
Run all the tests across a range of containers and on the host system:
npm run test
Run all the tests on a single system:
cd test
npx bats tests
docker-compose run ubuntu-curl bats /mnt/test/tests
2019-05-04 09:45:53 +02:00
Run single test on a single system::
cd test
npx bats tests/install-contents.bats
docker-compose run ubuntu-curl bats /mnt/test/tests/install-contents.bats
2019-05-04 09:45:53 +02:00
## Docker Tips
Using `docker-compose` in addition to `docker` for convenient mounting of `n` script and the tests into the container. Changes to the tests or to `n` itself are reflected immediately without needing to rebuild the containers.
`bats` is being mounted directly out of `node_modules` into the container as a manual install based on its own install script. This is a bit of a hack, but avoids needing to install `git` or `npm` for a full remote install of `bats`, and means everything on the same version of `bats`.
The containers each have:
* either curl or wget (or both) installed
Using `docker-compose` to run the container adds:
* specified `n` script mounted to `/usr/local/bin/n`
* `test/tests` mounted to `/mnt/test/tests`
2019-05-04 09:45:53 +02:00
* `node_modules/bats` provides `/usr/local/bin/bats` et al
* `.curlrc` with `--insecure` to allow use of proxy
So for example:
cd test
docker-compose run ubuntu-curl
# in container
n --version
bats /mnt/test/tests