fix(version): execute check current version function only when -v (#2263)

This commit is contained in:
Sergio Garcia
2023-04-24 12:45:59 +02:00
committed by GitHub
parent 63501a0d59
commit 8e63fa4594
3 changed files with 23 additions and 13 deletions

View File

@@ -6,6 +6,7 @@ from prowler.config.config import check_current_version
from prowler.providers.aws.aws_provider import get_aws_available_regions
MOCK_PROWLER_VERSION = "3.3.0"
MOCK_OLD_PROWLER_VERSION = "0.0.0"
def mock_prowler_get_latest_release(_):
@@ -25,10 +26,16 @@ class Test_Config:
@mock.patch("prowler.config.config.prowler_version", new=MOCK_PROWLER_VERSION)
def test_check_current_version_with_latest(self):
assert (
check_current_version(MOCK_PROWLER_VERSION)
== "(it is the latest version, yay!)"
check_current_version()
== f"Prowler {MOCK_PROWLER_VERSION} (it is the latest version, yay!)"
)
@mock.patch(
"prowler.config.config.requests.get", new=mock_prowler_get_latest_release
)
@mock.patch("prowler.config.config.prowler_version", new=MOCK_OLD_PROWLER_VERSION)
def test_check_current_version_with_old(self):
assert (
check_current_version("0.0.0")
== f"(latest is {MOCK_PROWLER_VERSION}, upgrade for the latest features)"
check_current_version()
== f"Prowler {MOCK_OLD_PROWLER_VERSION} (latest is {MOCK_PROWLER_VERSION}, upgrade for the latest features)"
)