diff --git a/tests/integration/test_charm.py b/tests/integration/test_charm.py index 007f4b037..19817bbad 100644 --- a/tests/integration/test_charm.py +++ b/tests/integration/test_charm.py @@ -319,11 +319,11 @@ def juju_reports_one_primary(unit_messages): async def test_audit_log(ops_test: OpsTest) -> None: """Test that audit log was created and contains actual audit data.""" leader_unit = await find_unit(ops_test, leader=True) - TMP_SERVICE_PATH = "tests/integration//audit.json.tmp" - AUDIT_LOG_SNAP_PATH = "/var/snap/charmed-mongodb/common/var/lib/mongodb/audit.json" - await leader_unit.scp_from(source=AUDIT_LOG_SNAP_PATH, destination=TMP_SERVICE_PATH) - with open(TMP_SERVICE_PATH, "r") as mongodb_service_file: + tmp_service_path = "tests/integration//audit.json.tmp" + audit_log_snap_path = "/var/snap/charmed-mongodb/common/var/lib/mongodb/audit.json" + await leader_unit.scp_from(source=audit_log_snap_path, destination=tmp_service_path) + with open(tmp_service_path, "r") as mongodb_service_file: audit_log = mongodb_service_file.readlines() # validate is not empty assert len(audit_log) > 0 - os.remove(TMP_SERVICE_PATH) + os.remove(tmp_service_path)