canonical / ops-scenario

State-transition testing SDK for Operator Framework Juju charms.
Apache License 2.0
10 stars 7 forks source link

chore!: remove deprecated functionality #123

Closed tonyandrewmeyer closed 3 months ago

tonyandrewmeyer commented 5 months ago

Removes empty files (placeholders for future things?) and functionality already marked as deprecated:

The context manager isn't quite a drop-in replacement for post_event (it is for pre_event). If there's code like this:

def post(charm):
    # do something on the charm that will change the state

out = ctx.run(event, State(), post_event=post)

Then that's not exactly the same as this:

def post(charm):
    # do something on the charm that will change the state

with ctx.manager(event, State()) as mgr:
    out = mgr.run()
    post(mgr.charm)

In the first case, the changes that post makes to the state are reflected in out, but in the second case they are not. I think this is everything working as intended and not a mistake I have made in the removal.

This seems ok to me - it's bad to be making changes to the state after the event has been run (inspecting is not so bad and pretty common based on my experience with Harness). Converting the Scenario tests that made use of this (to do the work in an event handler) was pretty straightforward.