Ejemplo n.º 1
0
    def test_get_min_required(self, mocker: MockerFixture, tmp_path: Path) -> None:
        """Test get_min_required."""
        mocker.patch.object(TFEnvManager, "terraform_block", {})
        tfenv = TFEnvManager(tmp_path)

        with pytest.raises(SystemExit) as excinfo:
            assert tfenv.get_min_required()
        assert excinfo.value.code

        mocker.patch.object(tfenv, "terraform_block", {"required_version": "!=0.12.0"})
        with pytest.raises(SystemExit) as excinfo:
            assert tfenv.get_min_required()
        assert excinfo.value.code

        mocker.patch.object(tfenv, "terraform_block", {"required_version": "~>0.12.0"})
        assert tfenv.get_min_required() == "0.12.0"
Ejemplo n.º 2
0
    def test_get_min_required(self, monkeypatch, tmp_path):
        """Test get_min_required."""
        monkeypatch.setattr(TFEnvManager, "terraform_block", {})
        tfenv = TFEnvManager(tmp_path)

        with pytest.raises(SystemExit) as excinfo:
            assert tfenv.get_min_required()
        assert excinfo.value.code

        monkeypatch.setattr(tfenv, "terraform_block",
                            {"required_version": "!=0.12.0"})
        with pytest.raises(SystemExit) as excinfo:
            assert tfenv.get_min_required()
        assert excinfo.value.code

        monkeypatch.setattr(tfenv, "terraform_block",
                            {"required_version": "~>0.12.0"})
        assert tfenv.get_min_required() == "0.12.0"