From ea9559c78449270d7c8bdf5d38fdf548ce12b028 Mon Sep 17 00:00:00 2001 From: GnomeZworc Date: Mon, 24 Aug 2026 21:19:15 +0200 Subject: [PATCH] f-43: test: fix default route create for nothing #43 Signed-off-by: GnomeZworc --- internal/dhcp/dhcp_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/internal/dhcp/dhcp_test.go b/internal/dhcp/dhcp_test.go index a2d5e60..94c7d7b 100644 --- a/internal/dhcp/dhcp_test.go +++ b/internal/dhcp/dhcp_test.go @@ -109,6 +109,32 @@ func TestGenerateConfig_NoDefaultGateway(t *testing.T) { } } +func TestGenerateConfig_NoDefaultGatewaySuppressesRouterOption(t *testing.T) { + conf := newConf(t, "192.168.1.0/29") + conf.DefaultGateway = nil + path, _, _ := GenerateConfig(conf) + content, _ := os.ReadFile(path) + + if !strings.Contains(string(content), "\ndhcp-option=3\n") { + t.Errorf("dhcp-option=3 nue absente : sans elle dnsmasq annonce sa propre adresse comme routeur\n%s", content) + } +} + +func TestGenerateConfig_VxlanEmitsNoRouterOption(t *testing.T) { + conf := newConf(t, "192.168.1.0/29") + conf.DefaultGateway = nil + + path, _, _ := GenerateConfig(conf) + content, _ := os.ReadFile(path) + + if !strings.Contains(string(content), "dhcp-option=121,") { + t.Fatalf("dhcp-option=121 attendue pour un subnet vxlan :\n%s", content) + } + if strings.Contains(string(content), "dhcp-option=3,") { + t.Errorf("un subnet vxlan est privé : aucune route par défaut ne doit être émise\n%s", content) + } +} + func TestGenerateConfig_ContainsVPCRoute(t *testing.T) { conf := newConf(t, "192.168.1.0/29") path, _, _ := GenerateConfig(conf)