Automation Test
Hangar project source code includes unit tests and validation tests.
Validation Test
In Container
Use following commands to run hangar validation tests in a container.
- Run
make build
to build hangar executable binary in container. - Run
make validation-test
to run validation tests for all hangar subcommands.
Without Container
To run validation tests on your local machine:
-
Build hangar on your local machine by following Building without a container.
-
Install python dependencies:
cd test/
pip install -r requirements.txt
pip install tox -
Run
scripts/registry.sh
, this will create a temporary private registry server for tests../scripts/registry.sh
-
To run specific test file:
# Set REGISTRY_AUTH_FILE environment variable to avoid permission denied error during tests.
export REGISTRY_AUTH_FILE="${HOME}/.config/containers/auth.json"
# Specify the REGISTRY_URL environment variable manually.
export REGISTRY_URL=127.0.0.1:5000
cd suite/
# Run specific test file.
pytest -s test_help.py
# Run specific test case.
pytest -s test_help.py::test_help -
Cleanup:
- Run
scripts/clean.sh
. - Delete the
registry
directory.
- Run
Unit Test
-
Run unit tests in container:
make test
-
Run unit tests on local machine:
./scripts/test.sh