|
@@ -1,4 +1,4 @@
|
|
-package utils
|
|
|
|
|
|
+package timeout
|
|
|
|
|
|
import (
|
|
import (
|
|
"bufio"
|
|
"bufio"
|
|
@@ -10,7 +10,7 @@ import (
|
|
"time"
|
|
"time"
|
|
)
|
|
)
|
|
|
|
|
|
-func TestTimeoutConnRead(t *testing.T) {
|
|
|
|
|
|
+func TestRead(t *testing.T) {
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
fmt.Fprintln(w, "hello")
|
|
fmt.Fprintln(w, "hello")
|
|
}))
|
|
}))
|
|
@@ -19,7 +19,7 @@ func TestTimeoutConnRead(t *testing.T) {
|
|
if err != nil {
|
|
if err != nil {
|
|
t.Fatalf("failed to create connection to %q: %v", ts.URL, err)
|
|
t.Fatalf("failed to create connection to %q: %v", ts.URL, err)
|
|
}
|
|
}
|
|
- tconn := NewTimeoutConn(conn, 1*time.Second)
|
|
|
|
|
|
+ tconn := New(conn, 1*time.Second)
|
|
|
|
|
|
if _, err = bufio.NewReader(tconn).ReadString('\n'); err == nil {
|
|
if _, err = bufio.NewReader(tconn).ReadString('\n'); err == nil {
|
|
t.Fatalf("expected timeout error, got none")
|
|
t.Fatalf("expected timeout error, got none")
|