operator icon indicating copy to clipboard operation
operator copied to clipboard

httpbin-demo: Add unit tests to fully exercise the status reporting

Open dwilding opened this issue 5 months ago • 1 comments

Our httpbin charm has a collect-status handler that accounts for various situations, but the unit tests don't cover all cases. The unit tests currently cover:

  • The charm going into active status under normal operation
  • The charm going into maintenance status if the container can't be reached - as a byproduct of trying to change the config in this situation

Other situations aren't covered. For example, the container is available but we haven't asked Pebble to create a service yet.

Some notes from discussion within Charm Tech:

Generally speaking, we should cover each case of the status reporting. We can consider the status reporting part of the charm's "user interface". It's fine to specifically test the status reporting. In some cases, this will be cleaner than always testing it as a byproduct of some other event. Best practice: Run update_status, don't run collect_unit_status.

I'm tracking this as an issue because it would be nice to link to the httpbin unit tests from the Ops docs.

dwilding avatar Sep 26 '25 03:09 dwilding

I had an initial go at this, but need to work on other things right now. I'll plan to revisit in 26.04

https://github.com/dwilding/operator/blob/httpbin-collect-status/examples/httpbin-demo/tests/unit/test_charm.py

dwilding avatar Oct 08 '25 23:10 dwilding