mirror of
https://github.com/labstack/echo.git
synced 2025-12-01 22:51:17 +02:00
Clean old Go versions
This commit is contained in:
committed by
Vishal Rana
parent
60f88a7a1c
commit
af1bfd5397
43
echo_test.go
43
echo_test.go
@@ -2,6 +2,7 @@ package echo
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
stdContext "context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
@@ -461,3 +462,45 @@ func TestHTTPError(t *testing.T) {
|
||||
})
|
||||
assert.Equal(t, "code=400, message=map[code:12]", err.Error())
|
||||
}
|
||||
|
||||
func TestEchoClose(t *testing.T) {
|
||||
e := New()
|
||||
errCh := make(chan error)
|
||||
|
||||
go func() {
|
||||
errCh <- e.Start(":0")
|
||||
}()
|
||||
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
|
||||
if err := e.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
assert.NoError(t, e.Close())
|
||||
|
||||
err := <-errCh
|
||||
assert.Equal(t, err.Error(), "http: Server closed")
|
||||
}
|
||||
|
||||
func TestEchoShutdown(t *testing.T) {
|
||||
e := New()
|
||||
errCh := make(chan error)
|
||||
|
||||
go func() {
|
||||
errCh <- e.Start(":0")
|
||||
}()
|
||||
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
|
||||
if err := e.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
ctx, cancel := stdContext.WithTimeout(stdContext.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
assert.NoError(t, e.Shutdown(ctx))
|
||||
|
||||
err := <-errCh
|
||||
assert.Equal(t, err.Error(), "http: Server closed")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user