-
Notifications
You must be signed in to change notification settings - Fork 88
Testing your changes
Tests are extremely important for stability of stuff in this repository.
In order to make sure your changes will not break anything / you fixed a bug / nobody can break the added functionality later:
-
cover the case as completely as possible
-
be sure your tests cover
check_mode
if applicable -
be sure that functionality that can be affected by your changes is also covered, if not, cover it
-
fixing a bug, write tests before changing related code, run them to see the bug exists. Then fix the bug, run the tests again to see the bug does not appear any more
We are assuming that you:
-
downloaded community.mysql repository
-
created directories
ansible_collections/general
in your home directory -
moved the repository
mv community.mysql ansible_collections/general/mysql
-
made some changes
-
added integration tests that cover your changes to one of the files in the
tests/integration/targets/test_mysql_*
directory (or you just want to run existing tests in order to check that your changes do not break currently covered code) -
if you do not know how to add tests for your case, create a pull request and ask other contributors there for help
-
Install docker daemon on your system, run it.
-
Download ansible-base repository.
-
Go to the ansible-base repository root directory.
-
Run
source hacking/env-setup
.
Note: Steps 2-4 are needed if you want to use devel version of ansible-test
utility.
-
Go to the
community.mysql
repository root directory. -
Run (change
test_mysql_query
to an appropriate test directory name):ansible-test integration test_mysql_query --docker --docker-no-pull -vvv > /tmp/test.log
Be sure you use default docker container, use the
--docker default
or just--docker
command-line option. -
If something goes wrong, you can check the output stored in
/tmp/test.log
.
To run sanity tests:
-
Be sure you ran
source hacking/env-setup
as described above. -
Run (change
mysql_query.py
to an appropriate file path):ansible-test sanity plugins/modules/mysql_query.py --docker --docker-no-pull
Be sure you use default docker container, use the
--docker default
or just--docker
command-line option.
-
You can just create a pull request in this repository and all sanity and integration tests (including yours) will run here automatically and you'll get a detailed report
-
Create a pull request and ask other contributors to help with running tests locally there.