-
Notifications
You must be signed in to change notification settings - Fork 88
Testing your changes
NOTE: For a complete guide, see Contributing
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
-
when 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/community
in your home directory -
moved the repository
mv community.mysql ansible_collections/community/mysql
-
made some changes
-
added integration tests that cover your changes to one of the files in the
tests/integration/targets/test_mysql_*/tasks
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 'python', 'pip', 'virtualenv', 'podman' and 'make' on your system.
-
Be sure you are in the
ansible_collections/community/mysql
directory (see the section above). -
Run (change
test_mysql_query
to an appropriate test target name if needed):make \ ansible="stable-2.14" \ db_engine_name="mariadb" \ db_engine_version="10.6.11" \ python="3.9" \ connector_name="pymysql" \ connector_version="0.9.3" \ target="test_mysql_query"
You can learn more about integration tests in TESTING.md
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 the--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 will see a detailed report.
-
Create a pull request without tests and ask other contributors to help with writing / running tests locally.