Pull request: all: imp some tests

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

Squashed commit of the following:

commit 6171420068d66808f069f280a81e0c60e61e5ce3
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Thu Mar 25 17:43:36 2021 +0300

    aghnet: imp test msgs

commit ed2880ff03ab0e41a77f07aad2caf13bf5f4bd9f
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Thu Mar 25 17:39:44 2021 +0300

    all: imp some tests
This commit is contained in:
Ainar Garipov
2021-03-25 18:03:29 +03:00
parent 3764c1dfe4
commit 27f4f05273
6 changed files with 42 additions and 40 deletions

View File

@@ -13,7 +13,7 @@ func TestIPDetector_detectSpecialNetwork(t *testing.T) {
var err error
ipd, err = NewIPDetector()
require.Nil(t, err)
require.NoError(t, err)
testCases := []struct {
name string

View File

@@ -49,7 +49,8 @@ func TestDHCPCDStaticConfig(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
r := bytes.NewReader(tc.data)
has, err := dhcpcdStaticConfig(r, "wlan0")
require.Nil(t, err)
require.NoError(t, err)
assert.Equal(t, tc.want, has)
})
}
@@ -86,7 +87,8 @@ func TestIfacesStaticConfig(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
r := bytes.NewReader(tc.data)
has, err := ifacesStaticConfig(r, "enp0s3")
require.Nil(t, err)
require.NoError(t, err)
assert.Equal(t, tc.want, has)
})
}

View File

@@ -8,9 +8,9 @@ import (
func TestGetValidNetInterfacesForWeb(t *testing.T) {
ifaces, err := GetValidNetInterfacesForWeb()
require.Nilf(t, err, "Cannot get net interfaces: %s", err)
require.NotEmpty(t, ifaces, "No net interfaces found")
require.NoErrorf(t, err, "cannot get net interfaces: %s", err)
require.NotEmpty(t, ifaces, "no net interfaces found")
for _, iface := range ifaces {
require.NotEmptyf(t, iface.Addresses, "No addresses found for %s", iface.Name)
require.NotEmptyf(t, iface.Addresses, "no addresses found for %s", iface.Name)
}
}