The govc tests use bats, a framework that provides a simple way to verify *NIX programs behave as expected.
Some of the govc tests require an ESX instance. These tests may be enabled with any ESX host with the following environment variable:
GOVC_TEST_URL=user:pass@<ESX_HOST>
There are two ways to run the tests locally:
- Via GitHub Actions in Docker - mimics how GitHub actions will execute the tests
- Natively on Linux and macOS - the fastest way to run the tests
This method of running the govc functional tests mimics how the project's associated GitHub actions will execute the tests when new pull requests are opened:
-
Install
act
:-
Linux (curl bash)
curl https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash
-
macOS
brew install act
-
-
Run the
govc-tests
action:act --env USER=user -j govc-tests
Note: To run the ESX tests with
act
, execute the following command:act --env USER=user --env GOVC_TEST_URL="user:pass@<ESX_HOST>" -j govc-tests
The fastest way to run the tests is to do so natively on Linux or macOS:
-
Install bats:
-
Debian / Ubuntu Linux
apt-get install bats
-
macOS
brew install bats
-
-
Some tests depend on the
ttylinux
images, and they can be downloaded with the following command:./govc/test/images/update.sh
The images are uploaded to the
$GOVC_TEST_URL
as needed by tests and can be removed with the following command:./govc/test/images/clean.sh
Note: Users of macOS will want to install gxargs
, greadlink
, and gmktemp
with the following command:
brew install coreutils findutils
-
The easiest way to run the tests is with the top-level Makefile:
make govc-test
The tests can also be run directly with the
bats
command:bats -t ./govc/test/
Finally, it's also possible to run the tests individually with:
./govc/test/cli.bats