Skip to content

Commit

Permalink
Fix scenario test
Browse files Browse the repository at this point in the history
  • Loading branch information
sed-i committed Nov 12, 2024
1 parent 8fbcbdf commit 59a7706
Showing 1 changed file with 4 additions and 23 deletions.
27 changes: 4 additions & 23 deletions tests/scenario/test_config_reporting_enabled.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,8 @@ def test_reporting_enabled(ctx):
# WHEN config-changed fires
out = ctx.run(ctx.on.config_changed(), state)

# THEN the config file is written WITHOUT the [analytics] section being rendered
simulated_pebble_filesystem = out.get_container("grafana").get_filesystem(ctx)
grafana_config_path = simulated_pebble_filesystem / "etc/grafana/grafana-config.ini"

config = ConfigParser()
config.read(grafana_config_path)
assert "analytics" not in config
# THEN the service layer does NOT include the "-disable-reporting" arg
assert "-disable-reporting" not in out.get_container("agent").layers.services["agent"].to_dict().command


def test_reporting_disabled(ctx):
Expand All @@ -29,19 +24,5 @@ def test_reporting_disabled(ctx):
# WHEN config-changed fires
out = ctx.run(ctx.on.config_changed(), state)

# THEN the config file is written WITH the [analytics] section being rendered
simulated_pebble_filesystem = out.get_container("grafana").get_filesystem(ctx)
grafana_config_path = simulated_pebble_filesystem / "etc/grafana/grafana-config.ini"

config = ConfigParser()
config.read(grafana_config_path)
assert "analytics" in config
assert dict(config["analytics"]) == {
"reporting_enabled": "false",
"check_for_updates": "false",
"check_for_plugin_updates": "false",
}

# AND the "grafana" service is restarted
# TODO Does it make sense to check this if the charm under test's lifetime is only for the config-changed?
# TODO How to assert this?
# THEN the service layer INCLUDES the "-disable-reporting" arg
assert "-disable-reporting" in out.get_container("agent").layers.services["agent"].to_dict().command

0 comments on commit 59a7706

Please sign in to comment.