A little-known experimental feature in scenario is check_builtin_sequences
. That is a function that essentially fires every possible event on your charm and hopes for the best.
Of course, that the charm does not raise any exception is a very low bar to set, but an important one nonetheless. It could help detect simple bugs and it’s a relatively inexpensive test to run, so, why not?
from scenario import State
from scenario.sequences import check_builtin_sequences
def test_builtin_events(mycharm):
ctx, _ = check_builtin_sequences(
mycharm,
meta={"name": "foo",
"requires": {"foo": {"interface": "bar"}},
"containers": {"baz": {"image": "tuktuk"}}
},
config={"options": {"foo": {"type": "string"}}},
template_state=State(
config={"foo": "bar"},
relations=[
Relation('foo'),
],
containers=[
Container('baz')
]),
)
assert len(ctx.emitted_events) == 36
This rather simple configuration already tests your charm with 36 different events!
There’s very little generic assertions worth making for every possible events in the general case, I suppose, except perhaps asserting that the charm set some sort of non-Unknown
status.
What do you think?