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