Files
rtnetmon/internal/cli/root_test.go
T
sneak ef3c373a12 Detect interfaces per platform; add macOS and single-interface support (closes #2)
Linux runs exactly as before when both bridge interfaces exist. When they do
not, the lone default-route interface is monitored, and a single interface now
draws a single UI pane instead of an empty second one.

macOS is newly supported: a running VPN tunnel (utun) is monitored as the
primary pane alongside the physical default-route interface, or the physical
interface alone when no VPN is up.

Detection lives in internal/netdetect: interface/route data types, pure
selection logic keyed on OS name, and route parsers, all unit-tested on Linux
for both platforms. Only the real route query and the per-platform TCP dial
binding (source address on Linux, IP_BOUND_IF on macOS) are build-tagged. Ping
argument construction is a pure, OS-keyed function. NewMonitor now takes a list
of interfaces.

Model: opus-4-8
2026-09-21 06:53:39 +00:00

34 lines
777 B
Go

package cli
import (
"testing"
)
// TestExecute tests that the CLI can be initialized
func TestExecute(t *testing.T) {
// This is a simple compilation test to ensure the CLI package compiles
// We can't easily test the full Execute() function as it starts the UI
// Test that rootCmd is properly initialized
if rootCmd == nil {
t.Fatal("rootCmd is nil")
}
if rootCmd.Use != "rtnetmon" {
t.Errorf("Expected rootCmd.Use to be 'rtnetmon', got '%s'", rootCmd.Use)
}
// Test that default configuration is set
if len(defaultReachabilityHosts) == 0 {
t.Error("defaultReachabilityHosts is empty")
}
if len(defaultPacketLossHosts) == 0 {
t.Error("defaultPacketLossHosts is empty")
}
if len(defaultTCPHosts) == 0 {
t.Error("defaultTCPHosts is empty")
}
}