mirror of
https://github.com/labstack/echo.git
synced 2024-12-22 20:06:21 +02:00
Fix server related tests (different error messages) on Windows
This commit is contained in:
parent
829ddef710
commit
3d2da856e3
@ -11,6 +11,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"os"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@ -965,7 +966,11 @@ func TestEcho_Start(t *testing.T) {
|
||||
case <-time.After(250 * time.Millisecond):
|
||||
t.Fatal("start did not error out")
|
||||
case err := <-errChan:
|
||||
assert.Contains(t, err.Error(), "bind: address already in use")
|
||||
expectContains := "bind: address already in use"
|
||||
if runtime.GOOS == "windows" {
|
||||
expectContains = "bind: Only one usage of each socket address"
|
||||
}
|
||||
assert.Contains(t, err.Error(), expectContains)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ import (
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@ -119,7 +120,11 @@ func TestStartConfig_Start(t *testing.T) {
|
||||
t.Errorf("missing error")
|
||||
return
|
||||
}
|
||||
assert.True(t, strings.Contains(err.Error(), "connect: connection refused"))
|
||||
expectContains := "connect: connection refused"
|
||||
if runtime.GOOS == "windows" {
|
||||
expectContains = "No connection could be made"
|
||||
}
|
||||
assert.True(t, strings.Contains(err.Error(), expectContains))
|
||||
}
|
||||
|
||||
func TestStartConfig_GracefulShutdown(t *testing.T) {
|
||||
@ -207,7 +212,11 @@ func TestStartConfig_GracefulShutdown(t *testing.T) {
|
||||
code, body, err = doGet(fmt.Sprintf("http://%v/ok", addr))
|
||||
assert.Error(t, err)
|
||||
if err != nil {
|
||||
assert.True(t, strings.Contains(err.Error(), "connect: connection refused"))
|
||||
expectContains := "connect: connection refused"
|
||||
if runtime.GOOS == "windows" {
|
||||
expectContains = "No connection could be made"
|
||||
}
|
||||
assert.True(t, strings.Contains(err.Error(), expectContains))
|
||||
}
|
||||
assert.Equal(t, 0, code)
|
||||
assert.Equal(t, "", body)
|
||||
|
Loading…
Reference in New Issue
Block a user