2019-06-10 09:33:19 +01:00
|
|
|
package home
|
2019-02-22 14:59:42 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2019-02-25 13:44:22 +00:00
|
|
|
"github.com/AdguardTeam/golibs/log"
|
2019-10-07 17:13:06 +01:00
|
|
|
"github.com/stretchr/testify/assert"
|
2019-02-22 14:59:42 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestGetValidNetInterfacesForWeb(t *testing.T) {
|
|
|
|
ifaces, err := getValidNetInterfacesForWeb()
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("Cannot get net interfaces: %s", err)
|
|
|
|
}
|
|
|
|
if len(ifaces) == 0 {
|
|
|
|
t.Fatalf("No net interfaces found")
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, iface := range ifaces {
|
|
|
|
if len(iface.Addresses) == 0 {
|
|
|
|
t.Fatalf("No addresses found for %s", iface.Name)
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Printf("%v", iface)
|
|
|
|
}
|
|
|
|
}
|
2019-10-07 17:13:06 +01:00
|
|
|
|
|
|
|
func TestSplitNext(t *testing.T) {
|
|
|
|
s := " a,b , c "
|
|
|
|
assert.True(t, SplitNext(&s, ',') == "a")
|
|
|
|
assert.True(t, SplitNext(&s, ',') == "b")
|
|
|
|
assert.True(t, SplitNext(&s, ',') == "c" && len(s) == 0)
|
|
|
|
}
|