1
0
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:
toimtoimtoim 2022-02-01 20:15:37 +02:00
parent 829ddef710
commit 3d2da856e3
No known key found for this signature in database
GPG Key ID: 468EA66F309CF886
2 changed files with 17 additions and 3 deletions

View File

@ -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)
}
}

View File

@ -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)