Beispiel #1
0
    def test_validate_version_good(self, mocker: MockFixture) -> None:
        ensure_installed = mocker.patch("opta.core.terraform.ensure_installed")
        get_version = mocker.patch("opta.core.terraform.Terraform.get_version")
        get_version.return_value = "1.0.0"

        Terraform.validate_version()

        ensure_installed.assert_called_once_with("terraform")
        get_version.assert_called_once()
Beispiel #2
0
    def test_validate_version_missing(self, mocker: MockFixture) -> None:
        ensure_installed = mocker.patch("opta.core.terraform.ensure_installed",
                                        side_effect=UserErrors("foobar"))
        get_version = mocker.patch("opta.core.terraform.Terraform.get_version")

        with pytest.raises(UserErrors) as e:
            Terraform.validate_version()

        ensure_installed.assert_called_once_with("terraform")
        assert str(e.value) == "foobar"

        get_version.assert_not_called()
Beispiel #3
0
    def test_validate_version_high(self, mocker: MockFixture) -> None:
        mocker.patch("opta.core.terraform.ensure_installed")
        get_version = mocker.patch("opta.core.terraform.Terraform.get_version")
        get_version.return_value = "2.0.0"

        with pytest.raises(UserErrors) as e:
            Terraform.validate_version()

        assert (
            str(e.value) ==
            "Invalid terraform version 2.0.0 -- must be less than 2.0.0. Check https://docs.opta.dev/installation/#prerequisites"
        )
        get_version.assert_called_once()
Beispiel #4
0
def dependency_check() -> None:
    """Check dependencies that are required globally"""
    Terraform.validate_version()