diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-26 08:15:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-26 08:15:20 +0000 |
commit | 87d772a7d708fec12f48cd8adc0dedff6e1025da (patch) | |
tree | 1fee344c64cc3f43074a01981e21126c8482a522 /src/go/collectors/go.d.plugin/modules/dnsmasq_dhcp/dhcp_test.go | |
parent | Adding upstream version 1.46.3. (diff) | |
download | netdata-upstream.tar.xz netdata-upstream.zip |
Adding upstream version 1.47.0.upstream/1.47.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/go/plugin/go.d/modules/dnsmasq_dhcp/dhcp_test.go (renamed from src/go/collectors/go.d.plugin/modules/dnsmasq_dhcp/dhcp_test.go) | 62 |
1 files changed, 61 insertions, 1 deletions
diff --git a/src/go/collectors/go.d.plugin/modules/dnsmasq_dhcp/dhcp_test.go b/src/go/plugin/go.d/modules/dnsmasq_dhcp/dhcp_test.go index b83b6a3f5..16e0f17d0 100644 --- a/src/go/collectors/go.d.plugin/modules/dnsmasq_dhcp/dhcp_test.go +++ b/src/go/plugin/go.d/modules/dnsmasq_dhcp/dhcp_test.go @@ -6,7 +6,7 @@ import ( "os" "testing" - "github.com/netdata/netdata/go/go.d.plugin/agent/module" + "github.com/netdata/netdata/go/plugins/plugin/go.d/agent/module" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -147,3 +147,63 @@ func TestDnsmasqDHCP_CollectFailedToOpenLeasesPath(t *testing.T) { job.LeasesPath = "" assert.Nil(t, job.Collect()) } + +func TestDnsmasqDHCP_parseDHCPRangeValue(t *testing.T) { + tests := map[string]struct { + input string + wantFail bool + }{ + "ipv4": { + input: "192.168.0.50,192.168.0.150,12h", + }, + "ipv4 with netmask": { + input: "192.168.0.50,192.168.0.150,255.255.255.0,12h", + }, + "ipv4 with netmask and tag": { + input: "set:red,1.1.1.50,1.1.2.150, 255.255.252.0", + }, + "ipv4 with iface": { + input: "enp3s0, 172.16.1.2, 172.16.1.254, 1h", + }, + "ipv4 with iface 2": { + input: "enp2s0.100, 192.168.100.2, 192.168.100.254, 1h", + }, + "ipv4 static": { + wantFail: true, + input: "192.168.0.0,static", + }, + "ipv6": { + input: "1234::2,1234::500", + }, + "ipv6 slacc": { + input: "1234::2,1234::500, slaac", + }, + "ipv6 with with prefix length and lease time": { + input: "1234::2,1234::500, 64, 12h", + }, + "ipv6 ra-only": { + wantFail: true, + input: "1234::,ra-only", + }, + "ipv6 ra-names": { + wantFail: true, + input: "1234::,ra-names", + }, + "ipv6 ra-stateless": { + wantFail: true, + input: "1234::,ra-stateless", + }, + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + v := parseDHCPRangeValue(test.input) + + if test.wantFail { + assert.Emptyf(t, v, "parsing '%s' must fail", test.input) + } else { + assert.NotEmptyf(t, v, "parsing '%s' must not fail", test.input) + } + }) + } +} |