diff --git a/operatorcert/static_tests/common/bundle.py b/operatorcert/static_tests/common/bundle.py index edc656a53..19c7f5429 100644 --- a/operatorcert/static_tests/common/bundle.py +++ b/operatorcert/static_tests/common/bundle.py @@ -248,6 +248,13 @@ def check_replaces_availability(bundle: Bundle) -> Iterator[CheckResult]: delimiter = ".v" if ".v" in replaces else "." replaces_version = replaces.split(delimiter, 1)[1] + if replaces_version == bundle.csv_operator_version: + yield Fail( + f"{bundle} attempts to replace itself. Please set " + "'spec.replaces' field to a different version in the CSV." + ) + return + ver_to_dir = { x.csv_operator_version: x.operator_version for x in bundle.operator.all_bundles() diff --git a/poetry.lock b/poetry.lock index 1fefc4036..cf891a488 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 2.3.4 and should not be changed by hand. +# This file is automatically @generated by Poetry 2.3.3 and should not be changed by hand. [[package]] name = "annotated-types" @@ -1075,21 +1075,21 @@ smmap = ">=3.0.1,<6" [[package]] name = "gitpython" -version = "3.1.46" +version = "3.1.50" description = "GitPython is a Python library used to interact with Git repositories" optional = false python-versions = ">=3.7" groups = ["main"] files = [ - {file = "gitpython-3.1.46-py3-none-any.whl", hash = "sha256:79812ed143d9d25b6d176a10bb511de0f9c67b1fa641d82097b0ab90398a2058"}, - {file = "gitpython-3.1.46.tar.gz", hash = "sha256:400124c7d0ef4ea03f7310ac2fbf7151e09ff97f2a3288d64a440c584a29c37f"}, + {file = "gitpython-3.1.50-py3-none-any.whl", hash = "sha256:d352abe2908d07355014abdd21ddf798c2a961469239afec4962e9da884858f9"}, + {file = "gitpython-3.1.50.tar.gz", hash = "sha256:80da2d12504d52e1f998772dc5baf6e553f8d2fcfe1fcc226c9d9a2ee3372dcc"}, ] [package.dependencies] gitdb = ">=4.0.1,<5" [package.extras] -doc = ["sphinx (>=7.1.2,<7.2)", "sphinx-autodoc-typehints", "sphinx_rtd_theme"] +doc = ["sphinx (>=7.4.7,<8)", "sphinx-autodoc-typehints", "sphinx_rtd_theme"] test = ["coverage[toml]", "ddt (>=1.1.1,!=1.4.3)", "mock ; python_version < \"3.8\"", "mypy (==1.18.2) ; python_version >= \"3.9\"", "pre-commit", "pytest (>=7.3.1)", "pytest-cov", "pytest-instafail", "pytest-mock", "pytest-sugar", "typing-extensions ; python_version < \"3.11\""] [[package]] diff --git a/tests/static_tests/common/test_bundle.py b/tests/static_tests/common/test_bundle.py index bda75f1dd..794935aee 100644 --- a/tests/static_tests/common/test_bundle.py +++ b/tests/static_tests/common/test_bundle.py @@ -804,6 +804,19 @@ def test_check_operator_version_directory_name( }, id="Nonexistent replaces version", ), + pytest.param( + None, + None, + "hello.v0.0.2", + [], + { + Fail( + "Bundle(hello/0.0.2) attempts to replace itself. Please set " + "'spec.replaces' field to a different version in the CSV." + ) + }, + id="Bundle attempts to replace itself", + ), ], ) @patch("operatorcert.static_tests.common.bundle.utils.get_ocp_supported_versions")