"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "internal/dhcpd/dhcpd_test.go" between
AdGuardHome-0.105.1.tar.gz and AdGuardHome-0.105.2.tar.gz

About: AdGuard Home is a network-wide ads & trackers blocking DNS server. It operates as a DNS server that re-routes tracking domains to a "black hole," thus preventing your devices from connecting to those servers.

dhcpd_test.go  (AdGuardHome-0.105.1):dhcpd_test.go  (AdGuardHome-0.105.2)
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
package dhcpd package dhcpd
import ( import (
"bytes"
"net" "net"
"os" "os"
"testing" "testing"
"time" "time"
"github.com/AdguardTeam/AdGuardHome/internal/aghtest" "github.com/AdguardTeam/AdGuardHome/internal/aghtest"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
skipping to change at line 133 skipping to change at line 132
assert.Equal(t, leases[0].HWAddr, dynLeases[0].HWAddr) assert.Equal(t, leases[0].HWAddr, dynLeases[0].HWAddr)
assert.Equal(t, leases[0].IP, staticLeases[0].IP) assert.Equal(t, leases[0].IP, staticLeases[0].IP)
assert.Equal(t, leases[1].HWAddr, staticLeases[1].HWAddr) assert.Equal(t, leases[1].HWAddr, staticLeases[1].HWAddr)
assert.Equal(t, leases[2].HWAddr, dynLeases[1].HWAddr) assert.Equal(t, leases[2].HWAddr, dynLeases[1].HWAddr)
} }
func TestOptions(t *testing.T) { func TestOptions(t *testing.T) {
testCases := []struct { testCases := []struct {
name string name string
optStr string optStr string
wantCode uint8
wantVal []byte wantVal []byte
wantCode uint8
}{{ }{{
name: "all_right_hex", name: "success_hex",
optStr: " 12 hex abcdef ", optStr: "12 hex abcdef",
wantCode: 12,
wantVal: []byte{0xab, 0xcd, 0xef}, wantVal: []byte{0xab, 0xcd, 0xef},
wantCode: 12,
}, { }, {
name: "bad_hex", name: "bad_hex",
optStr: " 12 hex abcdef1 ", optStr: "12 hex abcdefx",
wantVal: nil,
wantCode: 0, wantCode: 0,
}, { }, {
name: "all_right_ip", name: "success_ip",
optStr: "123 ip 1.2.3.4", optStr: "123 ip 1.2.3.4",
wantVal: net.IP{1, 2, 3, 4},
wantCode: 123,
}, {
name: "success_ipv6",
optStr: "123 ip ::1234",
wantVal: net.IP{
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0x12, 0x34,
},
wantCode: 123, wantCode: 123,
wantVal: net.IPv4(1, 2, 3, 4),
}, { }, {
name: "bad_code", name: "bad_code",
optStr: "256 ip 1.1.1.1", optStr: "256 ip 1.1.1.1",
wantVal: nil,
wantCode: 0, wantCode: 0,
}, { }, {
name: "negative_code", name: "negative_code",
optStr: "-1 ip 1.1.1.1", optStr: "-1 ip 1.1.1.1",
wantVal: nil,
wantCode: 0, wantCode: 0,
}, { }, {
name: "bad_ip", name: "bad_ip",
optStr: "12 ip 1.1.1.1x", optStr: "12 ip 1.1.1.1x",
wantVal: nil,
wantCode: 0, wantCode: 0,
}, { }, {
name: "bad_mode", name: "bad_mode",
wantVal: nil,
optStr: "12 x 1.1.1.1", optStr: "12 x 1.1.1.1",
wantCode: 0, wantCode: 0,
}} }}
for _, tc := range testCases { for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
code, val := parseOptionString(tc.optStr) code, val := parseOptionString(tc.optStr)
require.EqualValues(t, tc.wantCode, code) require.Equal(t, tc.wantCode, code)
if tc.wantVal != nil { if tc.wantVal != nil {
assert.True(t, bytes.Equal(tc.wantVal, val)) assert.Equal(t, tc.wantVal, val)
} }
}) })
} }
} }
 End of changes. 15 change blocks. 
10 lines changed or deleted 24 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)