Fix inconsistent arguments when creating a service in tests
-
Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA. As a benefit of being a GitLab Community Contributor, you receive complimentary access to GitLab Duo.
What does this MR do?
This MR fixes the creation of test services such that arguments passed to executor.createService() are consistent and realistic.
Why was this MR needed?
This executor.createService() method is only called by executor.createFromServiceDefinition() where several arguments are derived from the serviceDefinition common.Image argument whose Name string field is mandatory and has no proper meaning when defaulting to empty string. Meanwhile, several test cases in executors/docker/services_test.go call executor.createService() where the Name string field of the definition common.Image argument is "" while the value of the image string argument is "alpine". This combination of argument values cannot occur in reality, so the call of executor.createService() is not realistic. In addition, the image string argument is always an image name plus either a tag or a digest, as the service image name is split into name and version and the resulting (services.Service).ImageName value is passed to the image string argument of the executor.createService() method. See helpers/container/services/test/test.go for related test cases. Finally, the service string argument is also derived and would never be "build" when the image name is "alpine".
What's the best way to test this MR?
Run the test suite.
What are the relevant issue numbers?
n/a