2015-02-03 12:32:18 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestHostDomainAndIP(t *testing.T) {
|
|
|
|
Convey("Test Host File Domain and IP regex", t, func() {
|
|
|
|
Convey("1.1.1.1 should be IP and not domain", func() {
|
2015-02-03 14:53:57 +00:00
|
|
|
So(isIP("1.1.1.1"), ShouldEqual, true)
|
|
|
|
So(isDomain("1.1.1.1"), ShouldEqual, false)
|
2015-02-03 12:32:18 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
Convey("2001:470:20::2 should be IP and not domain", func() {
|
2015-02-03 14:53:57 +00:00
|
|
|
So(isIP("2001:470:20::2"), ShouldEqual, true)
|
|
|
|
So(isDomain("2001:470:20::2"), ShouldEqual, false)
|
2015-02-03 12:32:18 +00:00
|
|
|
})
|
|
|
|
|
2015-10-13 10:12:09 +00:00
|
|
|
Convey("`host` should not be domain and not IP", func() {
|
2018-02-01 07:39:47 +00:00
|
|
|
So(isDomain("host"), ShouldEqual, false)
|
2015-02-03 14:53:57 +00:00
|
|
|
So(isIP("host"), ShouldEqual, false)
|
2015-02-03 12:32:18 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
Convey("`123.test` should be domain and not IP", func() {
|
2015-02-03 14:53:57 +00:00
|
|
|
So(isDomain("123.test"), ShouldEqual, true)
|
|
|
|
So(isIP("123.test"), ShouldEqual, false)
|
2015-02-03 12:32:18 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
})
|
|
|
|
}
|