gabrieldemarmiesse / python-on-whales

An awesome Python wrapper for an awesome Docker CLI!
MIT License
557 stars 102 forks source link

Make tests less dependent on pulling images #526

Open LewisGaul opened 9 months ago

LewisGaul commented 9 months ago

A lot of testcases in test_image.py involve pulling (and then removing) container images, which has a number of downsides:

Many of these tests aren't actually aiming to test the pull mechanism, they just want an image present (e.g. test_image.py: :test_filter_when_listing()). As an alternative approach I'd suggest using a fixture to represent an image that should be present for the whole test run, e.g. one that we build ourselves.

gabrieldemarmiesse commented 9 months ago

Sure, I don't mind, as long as the complexity is low. And my low, I mean the base implementation should be < 30 lines of code.

d4nj1 commented 9 months ago

Hi, I like the idea. Maybe this could be achieved by using Dockers minimal registry https://docs.docker.com/registry/ run as a container like this: https://hub.docker.com/_/registry during test runtime. I guess you would have to provide/store a minimal Docker base image in this repo to be completely network independent.

LewisGaul commented 9 months ago

As someone who develops on the project I care more about it being possible to develop without network connection (e.g. on a train) even if it requires some initial setup. For example perhaps the first time you run the tests the registry image gets pulled and not cleaned up, such that it can be used for further development cycles without network connection. Or what I was suggesting is just to isolate the network dependency to tests that actually want to test pull functionality.