mirror of
https://github.com/labstack/echo.git
synced 2024-12-24 20:14:31 +02:00
Add some tests
This commit is contained in:
parent
931588a880
commit
3cdcc65b23
25
echo_test.go
25
echo_test.go
@ -409,9 +409,32 @@ func TestEchoStart(t *testing.T) {
|
|||||||
func TestEchoStartTLS(t *testing.T) {
|
func TestEchoStartTLS(t *testing.T) {
|
||||||
e := New()
|
e := New()
|
||||||
go func() {
|
go func() {
|
||||||
assert.NoError(t, e.StartTLS(":0", "_fixture/certs/cert.pem", "_fixture/certs/key.pem"))
|
err := e.StartTLS(":0", "_fixture/certs/cert.pem", "_fixture/certs/key.pem")
|
||||||
|
// Prevent the test to fail after closing the servers
|
||||||
|
if err != http.ErrServerClosed {
|
||||||
|
assert.NoError(t, err)
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
time.Sleep(200 * time.Millisecond)
|
time.Sleep(200 * time.Millisecond)
|
||||||
|
|
||||||
|
e.Close()
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestEchoStartAutoTLS(t *testing.T) {
|
||||||
|
e := New()
|
||||||
|
errChan := make(chan error, 0)
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
errChan <- e.StartAutoTLS(":0")
|
||||||
|
}()
|
||||||
|
time.Sleep(200 * time.Millisecond)
|
||||||
|
|
||||||
|
select {
|
||||||
|
case err := <-errChan:
|
||||||
|
assert.NoError(t, err)
|
||||||
|
default:
|
||||||
|
assert.NoError(t, e.Close())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testMethod(t *testing.T, method, path string, e *Echo) {
|
func testMethod(t *testing.T, method, path string, e *Echo) {
|
||||||
|
Loading…
Reference in New Issue
Block a user