Closed chpatton013 closed 3 years ago
This is adding quite a lot of lines to the project that I will not personally maintain, I would like to check how much demand there is for it before merging. If they are other users interested and ready to maintain testing and docker modules I will merge it.
@chpatton013
Can you add documentation that explains how to do the unit and integration testing?
I execute the Docker container based on the Dockerfile, and if it executes successful, then the integration test succeeded, right? How about the unit test? Where do I have to execute the aur_test.py and how is it used?
While I was working on #39 I wanted to add unit tests to make sure my new feature worked. I noticed that there weren't any unit tests yet, so I made some tests to cover the basic features I was aware of. In the process of working on those tests I made a few auxiliary changes to the library to make certain types of tests possible, and other easier to implement.
After I had passing unit tests I wanted to verify that this would work in a real playbook. I couldn't think of a great way to test that other than actually running a playbook, and the easiest way to encapsulate that as a reproducible test was with Docker. So I added a Dockerfile and a playbook to be used in that sort of integration test.
When I started working on these tests I had no experience with Ansible modules or the associated testing ecosystem. I did have plenty of experience with Python's
unittest
and mocking strategies, so I was able to skim Ansible's testing docs and get something working pretty quickly. However, I recommend reading through this documentation to get a handle on how Ansible recommends writing tests before reviewing this.