From 863e7366bb54cc90879edcb6c24ccb44721a14f4 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 7 Oct 2026 03:55:26 +0000 Subject: [PATCH] test: add tests for _match_iface_name Co-authored-by: Horizontal42 <75383519+Horizontal42@users.noreply.github.com> --- tests/test_iface.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/test_iface.py b/tests/test_iface.py index d3dbf57..795f333 100644 --- a/tests/test_iface.py +++ b/tests/test_iface.py @@ -3,6 +3,7 @@ from __future__ import annotations import socket from netsleuth.iface import ( + _match_iface_name, available_interfaces_hint, resolve_bind_target, usable_addresses, @@ -17,6 +18,30 @@ def up(**kw) -> dict[str, bool]: return kw +def test_match_iface_name_exact(): + assert _match_iface_name("eth0", ["eth0", "eth1"]) == "eth0" + + +def test_match_iface_name_case_insensitive_exact(): + assert _match_iface_name("ETH0", ["eth0", "eth1"]) == "eth0" + + +def test_match_iface_name_case_insensitive_exact_multiple(): + assert _match_iface_name("EtH0", ["eth0", "ETH0"]) == ["eth0", "ETH0"] + + +def test_match_iface_name_substring(): + assert _match_iface_name("eth", ["my-eth0-iface", "wlan0"]) == "my-eth0-iface" + + +def test_match_iface_name_substring_multiple(): + assert _match_iface_name("eth", ["eth0", "eth1"]) == ["eth0", "eth1"] + + +def test_match_iface_name_no_match(): + assert _match_iface_name("eth", ["wlan0", "lo"]) == [] + + def test_usable_addresses_picks_first_non_loopback_v4_and_v6(): v4, v6 = usable_addresses( [