Ejemplo n.º 1
0
def test_show_link_redhat():
    """Test alternatives.show_link on CentOS 8."""
    ld_data = b"auto\n/usr/bin/ld\n\n/usr/bin/ld.bfd\n50\n/usr/bin/ld.gold\n30\n"
    with patch.dict(alternatives.__grains__, {"os_family": "RedHat"}), patch(
            "salt.utils.files.fopen",
            mock_open(read_data={"/var/lib/alternatives/ld": ld_data}),
    ):
        assert alternatives.show_link("ld") == "/usr/bin/ld"
Ejemplo n.º 2
0
def test_show_link_suse():
    """Test alternatives.show_link on openSUSE Leap 42.3."""
    ld_data = b"auto\n/usr/bin/ld\n\n/usr/bin/ld.bfd\n2\n\n"
    with patch.dict(alternatives.__grains__, {"os_family": "Suse"}), patch(
            "salt.utils.files.fopen",
            mock_open(read_data={"/var/lib/rpm/alternatives/ld": ld_data}),
    ):
        assert alternatives.show_link("ld") == "/usr/bin/ld"
Ejemplo n.º 3
0
def test_show_link_debian():
    """Test alternatives.show_link on Debian 10."""
    run_all_mock = MagicMock(return_value={
        "retcode": 0,
        "stderr": "",
        "stdout": ALTERNATIVE_QUERY_EDITOR
    })
    with patch.dict(alternatives.__grains__,
                    {"os_family": "Debian"}), patch.dict(
                        alternatives.__salt__, {"cmd.run_all": run_all_mock}):
        assert alternatives.show_link("editor") == "/usr/bin/editor"