fix units test again
This commit is contained in:
parent
ace61f4f30
commit
8e2192a4b5
@ -1317,7 +1317,7 @@ def validate_bun():
|
||||
if not path_ops.samefile(bun_path, constants.Bun.DEFAULT_PATH):
|
||||
console.info(f"Using custom Bun path: {bun_path}")
|
||||
bun_version = get_bun_version()
|
||||
if not bun_version:
|
||||
if bun_version is None:
|
||||
console.error(
|
||||
"Failed to obtain bun version. Make sure the specified bun path in your config is correct."
|
||||
)
|
||||
|
@ -126,39 +126,22 @@ def test_validate_none_bun_path(mocker):
|
||||
prerequisites.validate_bun()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"exists,samefile",
|
||||
[
|
||||
(False, None),
|
||||
(True, False),
|
||||
],
|
||||
)
|
||||
def test_validate_invalid_bun_path(
|
||||
exists,
|
||||
samefile,
|
||||
mocker,
|
||||
):
|
||||
"""Test that an error is thrown when a custom specified bun path is not valid
|
||||
or does not exist.
|
||||
|
||||
Args:
|
||||
exists: Whether the bun path exists.
|
||||
samefile: Whether the bun path is the same file.
|
||||
mocker: Pytest mocker object.
|
||||
"""
|
||||
mock_path = mocker.Mock()
|
||||
mock_path.exists.return_value = exists
|
||||
mock_path.samefile.return_value = samefile
|
||||
mocker.patch("reflex.utils.path_ops.get_bun_path", return_value=mock_path)
|
||||
mocker.patch("reflex.utils.path_ops.samefile", return_value=False)
|
||||
mocker.patch("reflex.utils.prerequisites.get_bun_version", return_value=None)
|
||||
|
||||
with pytest.raises(typer.Exit):
|
||||
prerequisites.validate_bun()
|
||||
mock_path.exists.assert_called_once()
|
||||
if exists:
|
||||
mock_path.samefile.assert_called_once()
|
||||
else:
|
||||
mock_path.samefile.assert_not_called()
|
||||
|
||||
|
||||
def test_validate_bun_path_incompatible_version(mocker):
|
||||
@ -170,6 +153,7 @@ def test_validate_bun_path_incompatible_version(mocker):
|
||||
mock_path = mocker.Mock()
|
||||
mock_path.samefile.return_value = False
|
||||
mocker.patch("reflex.utils.path_ops.get_bun_path", return_value=mock_path)
|
||||
mocker.patch("reflex.utils.path_ops.samefile", return_value=False)
|
||||
mocker.patch(
|
||||
"reflex.utils.prerequisites.get_bun_version",
|
||||
return_value=version.parse("0.6.5"),
|
||||
@ -177,8 +161,6 @@ def test_validate_bun_path_incompatible_version(mocker):
|
||||
|
||||
with pytest.raises(typer.Exit):
|
||||
prerequisites.validate_bun()
|
||||
mock_path.exists.assert_called_once()
|
||||
mock_path.samefile.assert_called_once()
|
||||
|
||||
|
||||
def test_remove_existing_bun_installation(mocker):
|
||||
|
Loading…
Reference in New Issue
Block a user