Skip to content

Conversation

lucasgameiroborges
Copy link

Typically: to save CI time, when the same check were executed in a Juju 3-specific way already
"""
if juju_has_secrets:
pytest.skip("Skipping legacy secrets tests")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had already the whole test suite running with and without secrets (unit-juju2 and unit-juju3 respectively), the only change needed was to adapt the few tests that only ran in one or the other, and remove this fixtures.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging those 2 suites into one will be addressed in a follow-up PR!

@patch_network_get(private_address="1.1.1.1")
@patch("charm.PostgresqlOperatorCharm._on_leader_elected")
@pytest.mark.usefixtures("use_caplog")
def test_delete_existing_password_secrets(self, _, __):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar to what was done in canonical/postgresql-operator#425, this test got removed and test_delete_password runs with and without secrets

):
# as this test checks for a migration from databag to secrets,
# there's no need for this test when secrets are not enabled.
if not juju_has_secrets:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here and on the test below, same idea from canonical/postgresql-operator#425

Comment on lines +17 to +18
tc.assertEqual(len(first_password), 16)
tc.assertIsNotNone(re.fullmatch("[a-zA-Z0-9\b]{16}$", first_password))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can just use regular asserts in such cases. No need to keep the test case just for that.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, will refactor this together with merging the 2 suites in the follow-up PR.

Lucas Gameiro Borges added 2 commits April 25, 2024 23:02
@lucasgameiroborges lucasgameiroborges merged commit 8acbc9d into main Apr 25, 2024
@lucasgameiroborges lucasgameiroborges deleted the lucas/convert-tests branch April 25, 2024 23:59
BON4 pushed a commit to BON4/postgresql-k8s-operator that referenced this pull request May 20, 2024
… secrets in every test (canonical#452)

* convert all tests to pytest

* remove secret remove hook

* Revert "remove secret remove hook"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants