// Copyright 2025, IPng Networks GmbH, Pim van Pelt package agentx import ( "flag" "testing" ) func TestAgentXAddrFlag(t *testing.T) { // Test that the flag is registered with correct default if *AgentXAddr != "localhost:705" { t.Errorf("Expected default AgentX address to be 'localhost:705', got '%s'", *AgentXAddr) } } func TestAgentXAddrFlagParsing(t *testing.T) { // Save original flag value originalAddr := *AgentXAddr defer func() { *AgentXAddr = originalAddr }() // Test Unix socket path testAddr := "/var/run/test.sock" *AgentXAddr = testAddr if *AgentXAddr != testAddr { t.Errorf("Expected AgentX address to be '%s', got '%s'", testAddr, *AgentXAddr) } // Test TCP address testAddr = "192.168.1.1:705" *AgentXAddr = testAddr if *AgentXAddr != testAddr { t.Errorf("Expected AgentX address to be '%s', got '%s'", testAddr, *AgentXAddr) } } func TestFlagRegistration(t *testing.T) { // Test that our flag is properly registered f := flag.Lookup("agentx.addr") if f == nil { t.Error("Expected agentx.addr flag to be registered") return } if f.DefValue != "localhost:705" { t.Errorf("Expected flag default value to be 'localhost:705', got '%s'", f.DefValue) } if f.Usage != "Address to connect to (hostname:port or Unix socket path)" { t.Errorf("Unexpected flag usage string: %s", f.Usage) } }