schireson / pytest-mock-resources

Pytest Fixtures that let you actually test against external resource (Postgres, Mongo, Redshift...) dependent code.
https://pytest-mock-resources.readthedocs.io/en/latest/quickstart.html
MIT License
179 stars 19 forks source link

Allow specificying an image when using pmr cli #125

Closed michaelbukachi closed 2 years ago

michaelbukachi commented 2 years ago

It would be nice if we can specify the image version downloaded when running pmr. Currently, the image versions are hardcoded in the code. Maybe we can use an environment variable? :thinking:

oakhan3 commented 2 years ago

Thats a great thought, the CLI is simple enough where we could do something like:

import os
image = os.getenv("POSTGRES_IMAGE", "postgres:9.6.10-alpine")

and drop the replacement at https://github.com/schireson/pytest-mock-resources/blob/6f3c083d85c02892028e332897ad860b125c68ac/src/pytest_mock_resources/cli.py#L31

similarly we could do the above for https://github.com/schireson/pytest-mock-resources/blob/6f3c083d85c02892028e332897ad860b125c68ac/src/pytest_mock_resources/container/postgres.py#L31

to garner consistency.

@michaelbukachi are you up for PR'ing the change?

michaelbukachi commented 2 years ago

@oakhan3 On it :smiley:

michaelbukachi commented 2 years ago

@oakhan3 For the second case, don't we have the ability to override the image already by defining the pmr_postgres_config?

DanCardin commented 2 years ago

Ideally (imo) it would pick up on pmr_postgres_config, but that likely requires at least some miminal set of assumptions about how pytest is invoked.

With that being said, i would prefer PMR_POSTGRES_IMAGE because that's the environment variable fallback that gets used by PMR proper already