Pull request: all: imp errcheck in tests

Merge in DNS/adguard-home from imp-errcheck to master

Squashed commit of the following:

commit ed046b8ef59a092a27c623cd14b3fc2ef305fc3d
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Thu Feb 4 15:00:04 2021 +0300

    stats: imp cleanup more

commit e53a9240d3e3eec2417c768b98c267a8cd54d992
Merge: da734317 676f8c76
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Thu Feb 4 14:59:40 2021 +0300

    Merge branch 'master' into imp-errcheck

commit da734317035543b52e5a9030813084bdc92ba90a
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Thu Feb 4 14:37:26 2021 +0300

    stats: imp cleanup

commit 8b4ad150129111a09be6fa2944a21bd06ab8e5a1
Merge: 385c8a6c 5081ead0
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Thu Feb 4 14:34:26 2021 +0300

    Merge branch 'master' into imp-errcheck

commit 385c8a6c91e3bf07a457da370c8cc77820b91600
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Fri Jan 29 20:41:57 2021 +0300

    all: imp errcheck in tests
This commit is contained in:
Ainar Garipov
2021-02-04 15:12:34 +03:00
parent 676f8c7671
commit fa33568fab
10 changed files with 65 additions and 33 deletions

View File

@@ -45,12 +45,17 @@ func TestDB(t *testing.T) {
l.HWAddr, _ = net.ParseMAC("aa:aa:aa:aa:aa:aa")
exp1 := time.Now().Add(time.Hour)
l.Expiry = exp1
s.srv4.(*v4Server).addLease(&l)
srv4, ok := s.srv4.(*v4Server)
assert.True(t, ok)
srv4.addLease(&l)
l2 := Lease{}
l2.IP = net.IP{192, 168, 10, 101}
l2.HWAddr, _ = net.ParseMAC("aa:aa:aa:aa:aa:bb")
s.srv4.AddStaticLease(l2)
err = s.srv4.AddStaticLease(l2)
assert.Nil(t, err)
_ = os.Remove("leases.db")
s.dbStore()

View File

@@ -69,7 +69,8 @@ func TestV4StaticLeaseAddReplaceDynamic(t *testing.T) {
notify: notify4,
}
sIface, err := v4Create(conf)
s := sIface.(*v4Server)
s, ok := sIface.(*v4Server)
assert.True(t, ok)
assert.Nil(t, err)
// add dynamic lease
@@ -121,7 +122,8 @@ func TestV4StaticLeaseGet(t *testing.T) {
notify: notify4,
}
sIface, err := v4Create(conf)
s := sIface.(*v4Server)
s, ok := sIface.(*v4Server)
assert.True(t, ok)
assert.Nil(t, err)
s.conf.dnsIPAddrs = []net.IP{{192, 168, 10, 1}}
@@ -184,7 +186,8 @@ func TestV4DynamicLeaseGet(t *testing.T) {
},
}
sIface, err := v4Create(conf)
s := sIface.(*v4Server)
s, ok := sIface.(*v4Server)
assert.True(t, ok)
assert.Nil(t, err)
s.conf.dnsIPAddrs = []net.IP{{192, 168, 10, 1}}

View File

@@ -64,7 +64,8 @@ func TestV6StaticLeaseAddReplaceDynamic(t *testing.T) {
notify: notify6,
}
sIface, err := v6Create(conf)
s := sIface.(*v6Server)
s, ok := sIface.(*v6Server)
assert.True(t, ok)
assert.Nil(t, err)
// add dynamic lease
@@ -113,7 +114,8 @@ func TestV6GetLease(t *testing.T) {
notify: notify6,
}
sIface, err := v6Create(conf)
s := sIface.(*v6Server)
s, ok := sIface.(*v6Server)
assert.True(t, ok)
assert.Nil(t, err)
s.conf.dnsIPAddrs = []net.IP{net.ParseIP("2000::1")}
s.sid = dhcpv6.Duid{
@@ -173,7 +175,8 @@ func TestV6GetDynamicLease(t *testing.T) {
notify: notify6,
}
sIface, err := v6Create(conf)
s := sIface.(*v6Server)
s, ok := sIface.(*v6Server)
assert.True(t, ok)
assert.Nil(t, err)
s.conf.dnsIPAddrs = []net.IP{net.ParseIP("2000::1")}
s.sid = dhcpv6.Duid{