charmed-kubernetes / pytest-operator

Apache License 2.0
7 stars 13 forks source link

application config management #70

Closed PietroPasotti closed 2 years ago

PietroPasotti commented 2 years ago

I'm not sure if this feature is there already (and I haven't found it), but it would be nice to support more natively application config management (set, get).

At the moment the best way I could find to config-set is:

await ops_test.juju("config", APP_NAME, "key=value")

However, this makes unsetting keys impossible: await ops_test.juju("config", APP_NAME, 'key=""') --> 'key' is now '""' (quoted quotation marks), not None. I solved this by doing os.system(f'juju config {APP_NAME} key=""')

But this is an indication that a unit config wrapper would be very welcome :)

addyess commented 2 years ago

This is a feature available through libjuju.

async def test_my_config_changes(ops_test)
    app = ops_test.model.applications[APP_NAME]
    await app.set_config({"key": "value"})
    # test something happening with this key=value
    await app.reset_config(["key"])