2013-09-02 05:41:57 +04:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/tls"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestTransporterTimeout(t *testing.T) {
|
|
|
|
|
|
|
|
conf := tls.Config{}
|
|
|
|
|
|
|
|
ts := newTransporter("http", conf, time.Second)
|
|
|
|
|
2013-09-03 03:54:46 +04:00
|
|
|
ts.Get("http://google.com")
|
2013-09-03 01:05:35 +04:00
|
|
|
_, err := ts.Get("http://google.com:9999") // it doesn't exisit
|
2013-09-02 05:41:57 +04:00
|
|
|
if err == nil || err.Error() != "Wait Response Timeout: 1s" {
|
2013-09-03 03:58:45 +04:00
|
|
|
t.Fatal("timeout error: ", err.Error())
|
2013-09-02 05:41:57 +04:00
|
|
|
}
|
|
|
|
|
2013-09-03 01:05:35 +04:00
|
|
|
_, err = ts.Post("http://google.com:9999", nil) // it doesn't exisit
|
2013-09-02 05:41:57 +04:00
|
|
|
if err == nil || err.Error() != "Wait Response Timeout: 1s" {
|
|
|
|
t.Fatal("timeout error: ", err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err = ts.Get("http://www.google.com")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal("get error")
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err = ts.Post("http://www.google.com", nil)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal("post error")
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|