echoip/ifconfig_test.go

22 lines
520 B
Go
Raw Normal View History

2013-09-08 19:37:41 +02:00
package main
import "testing"
func TestIsCLi(t *testing.T) {
2014-11-01 14:36:57 +01:00
userAgents := []string{"curl/7.26.0", "Wget/1.13.4 (linux-gnu)",
"fetch libfetch/2.0"}
2013-09-08 19:37:41 +02:00
2014-11-01 14:36:57 +01:00
for _, userAgent := range userAgents {
if !isCli(userAgent) {
t.Errorf("Expected true for %s", userAgent)
}
}
2013-09-08 19:37:41 +02:00
2014-11-01 14:36:57 +01:00
browserUserAgent := "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) " +
"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.28 " +
"Safari/537.36"
if isCli(browserUserAgent) {
t.Errorf("Expected false for %s", browserUserAgent)
}
2013-09-08 19:37:41 +02:00
}