2019-06-10 11:33:19 +03:00
|
|
|
package home
|
2019-02-22 17:59:42 +03:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2019-02-25 16:44:22 +03:00
|
|
|
"github.com/AdguardTeam/golibs/log"
|
2019-10-07 19:13:06 +03:00
|
|
|
"github.com/stretchr/testify/assert"
|
2019-02-22 17:59:42 +03: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 19:13:06 +03: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)
|
|
|
|
}
|