Skip to content

Commit

Permalink
revert new test changes
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasgameiroborges committed Apr 30, 2024
1 parent 1bd9618 commit 4008f9a
Showing 1 changed file with 1 addition and 26 deletions.
27 changes: 1 addition & 26 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1719,7 +1719,7 @@ def test_scope_obj(harness):


@patch_network_get(private_address="1.1.1.1")
def test_get_secret(harness):
def test_get_secret_from_databag(harness):
with patch("charm.PostgresqlOperatorCharm._on_leader_elected"):
rel_id = harness.model.get_relation(PEER).id
# App level changes require leader privileges
Expand Down Expand Up @@ -1814,31 +1814,6 @@ def test_set_secret_in_databag(harness, only_without_juju_secrets):
harness.charm.set_secret("test", "password", "test")


@patch_network_get(private_address="1.1.1.1")
def test_set_secret_with_juju_secret(harness):
# this test is the juju3 version of the previous test, but it can run on both versions
# as it is backwards compatible behavior (usage of set_secret/get_secret)
with patch("charm.PostgresqlOperatorCharm._on_leader_elected"):
rel_id = harness.model.get_relation(PEER).id
harness.set_leader()

# Test application scope.
assert "password" not in harness.get_relation_data(rel_id, harness.charm.app.name)
harness.charm.set_secret("app", "password", "test-password")
assert harness.charm.get_secret("app", "password") == "test-password"
harness.charm.set_secret("app", "password", None)
assert "password" not in harness.get_relation_data(rel_id, harness.charm.app.name)

# Test unit scope.
assert "password" not in harness.get_relation_data(rel_id, harness.charm.unit.name)
harness.charm.set_secret("unit", "password", "test-password")
assert harness.charm.get_secret("unit", "password") == "test-password"
harness.charm.set_secret("unit", "password", None)
assert "password" not in harness.get_relation_data(rel_id, harness.charm.unit.name)
with pytest.raises(RuntimeError):
harness.charm.set_secret("test", "password", "test")


@pytest.mark.parametrize("scope,is_leader", [("app", True), ("unit", True), ("unit", False)])
@patch_network_get(private_address="1.1.1.1")
def test_set_reset_new_secret(harness, scope, is_leader):
Expand Down

0 comments on commit 4008f9a

Please sign in to comment.