Skip to content

Commit

Permalink
test: fix blocked status and blocked status tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hpidcock committed Nov 21, 2024
1 parent ce266fa commit e5204f9
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 2 deletions.
27 changes: 27 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
description = "juju controller charm shell";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
};

outputs = { self, nixpkgs, ... } @ inputs:
let
forAllSystems = inputs.nixpkgs.lib.genAttrs [
"aarch64-linux"
"x86_64-linux"
"aarch64-darwin"
];
in
{
devShells = forAllSystems (system: {
default =
let
pkgs = nixpkgs.legacyPackages.${system};
in
pkgs.mkShell {
name = "juju-controller-charm";
# Enable experimental features without having to specify the argument
NIX_CONFIG = "experimental-features = nix-command flakes";
nativeBuildInputs = with pkgs; [
coreutils
findutils
zsh
python312
];
shellHook = ''
exec zsh
'';
};
});
};
}
2 changes: 1 addition & 1 deletion src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def _on_metrics_endpoint_relation_created(self, event: RelationJoinedEvent):
except AgentConfException as e:
logger.error('cannot read controller API port from agent configuration: %s', e)
self.unit.status = BlockedStatus(
f"can't read controller API port from agent.conf: {e}")
f"cannot read controller API port from agent configuration: {e}")
return

metrics_endpoint = MetricsEndpointProvider(
Expand Down
3 changes: 2 additions & 1 deletion tests/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ def test_apiaddresses_missing_status(self, *_):
harness.add_relation('metrics-endpoint', 'prometheus-k8s')
harness.evaluate_status()
self.assertEqual(harness.charm.unit.status, BlockedStatus(
"can't read controller API port from agent.conf: agent.conf key 'apiaddresses' missing"
"cannot read controller API port from agent configuration: "
"agent.conf key 'apiaddresses' missing"
))

@patch("builtins.open", new_callable=mock_open, read_data=agent_conf_ipv4)
Expand Down

0 comments on commit e5204f9

Please sign in to comment.