Skip to content

Commit

Permalink
fix: fix unit test and change integration test by deploying postgresql
Browse files Browse the repository at this point in the history
  • Loading branch information
amandahla committed Sep 10, 2024
1 parent 4239595 commit da5cc2c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def _pebble_layer(self) -> pebble.LayerDict:
"summary": "maubot",
"command": "bash -c 'python3 -m maubot -c /data/config.yaml'",
"startup": "enabled",
"working-dir": "/data"
"working-dir": "/data",
}
},
}
Expand Down
12 changes: 9 additions & 3 deletions tests/integration/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,20 @@ async def test_build_and_deploy(
):
"""
arrange: set up the test Juju model.
act: build and deploy the Maubot charm .
assert: the Maubot charm becomes blocked (postgresql integration is required)
act: build and deploy the Maubot charm, check if is blocked and deploy postgresql.
assert: the Maubot charm becomes active once is integrated with postgresql.
"""
charm = pytestconfig.getoption("--charm-file")
maubot_image = pytestconfig.getoption("--maubot-image")
assert maubot_image
if not charm:
charm = await ops_test.build_charm(".")
assert ops_test.model
await ops_test.model.deploy(f"./{charm}", resources={"maubot-image": maubot_image})
maubot = await ops_test.model.deploy(f"./{charm}", resources={"maubot-image": maubot_image})
await ops_test.model.wait_for_idle(timeout=600, status="blocked")

postgresql_k8s = await ops_test.model.deploy("postgresql-k8s", channel="14/stable", trust=True)
await ops_test.model.wait_for_idle(timeout=900)
await ops_test.model.add_relation(maubot.name, postgresql_k8s.name)

await ops_test.model.wait_for_idle(timeout=900, status="active")
3 changes: 2 additions & 1 deletion tests/unit/test_charm.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.

# pylint: disable=protected-access
# pylint: disable=protected-access, duplicate-code

"""Unit tests."""

Expand Down Expand Up @@ -64,6 +64,7 @@ def test_maubot_pebble_ready(harness):
"summary": "maubot",
"command": "bash -c 'python3 -m maubot -c /data/config.yaml'",
"startup": "enabled",
"working-dir": "/data",
}
},
}
Expand Down

0 comments on commit da5cc2c

Please sign in to comment.