mirror of
https://github.com/strukturag/nextcloud-spreed-signaling
synced 2026-03-14 14:35:44 +01:00
Fix formatting of errors in "assert.Fail" calls.
This commit is contained in:
parent
447bdb827c
commit
75d311c67c
14 changed files with 120 additions and 127 deletions
|
|
@ -493,8 +493,8 @@ func TestBackendConfiguration_Etcd(t *testing.T) {
|
|||
if backends := sortBackends(cfg.GetBackends()); assert.Len(backends, 1) &&
|
||||
assert.Equal(url1, backends[0].url) &&
|
||||
assert.Equal(initialSecret1, string(backends[0].secret)) {
|
||||
if backend := cfg.GetBackend(mustParse(url1)); backend != backends[0] {
|
||||
assert.Fail("Expected backend %+v, got %+v", backends[0], backend)
|
||||
if backend := cfg.GetBackend(mustParse(url1)); assert.NotNil(backend) {
|
||||
assert.Equal(backends[0], backend)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -504,8 +504,8 @@ func TestBackendConfiguration_Etcd(t *testing.T) {
|
|||
if backends := sortBackends(cfg.GetBackends()); assert.Len(backends, 1) &&
|
||||
assert.Equal(url1, backends[0].url) &&
|
||||
assert.Equal(secret1, string(backends[0].secret)) {
|
||||
if backend := cfg.GetBackend(mustParse(url1)); backend != backends[0] {
|
||||
assert.Fail("Expected backend %+v, got %+v", backends[0], backend)
|
||||
if backend := cfg.GetBackend(mustParse(url1)); assert.NotNil(backend) {
|
||||
assert.Equal(backends[0], backend)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -520,10 +520,10 @@ func TestBackendConfiguration_Etcd(t *testing.T) {
|
|||
assert.Equal(secret1, string(backends[0].secret)) &&
|
||||
assert.Equal(url2, backends[1].url) &&
|
||||
assert.Equal(secret2, string(backends[1].secret)) {
|
||||
if backend := cfg.GetBackend(mustParse(url1)); backend != backends[0] {
|
||||
assert.Fail("Expected backend %+v, got %+v", backends[0], backend)
|
||||
} else if backend := cfg.GetBackend(mustParse(url2)); backend != backends[1] {
|
||||
assert.Fail("Expected backend %+v, got %+v", backends[1], backend)
|
||||
if backend := cfg.GetBackend(mustParse(url1)); assert.NotNil(backend) {
|
||||
assert.Equal(backends[0], backend)
|
||||
} else if backend := cfg.GetBackend(mustParse(url2)); assert.NotNil(backend) {
|
||||
assert.Equal(backends[1], backend)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -540,12 +540,12 @@ func TestBackendConfiguration_Etcd(t *testing.T) {
|
|||
assert.Equal(secret2, string(backends[1].secret)) &&
|
||||
assert.Equal(url3, backends[2].url) &&
|
||||
assert.Equal(secret3, string(backends[2].secret)) {
|
||||
if backend := cfg.GetBackend(mustParse(url1)); backend != backends[0] {
|
||||
assert.Fail("Expected backend %+v, got %+v", backends[0], backend)
|
||||
} else if backend := cfg.GetBackend(mustParse(url2)); backend != backends[1] {
|
||||
assert.Fail("Expected backend %+v, got %+v", backends[1], backend)
|
||||
} else if backend := cfg.GetBackend(mustParse(url3)); backend != backends[2] {
|
||||
assert.Fail("Expected backend %+v, got %+v", backends[2], backend)
|
||||
if backend := cfg.GetBackend(mustParse(url1)); assert.NotNil(backend) {
|
||||
assert.Equal(backends[0], backend)
|
||||
} else if backend := cfg.GetBackend(mustParse(url2)); assert.NotNil(backend) {
|
||||
assert.Equal(backends[1], backend)
|
||||
} else if backend := cfg.GetBackend(mustParse(url3)); assert.NotNil(backend) {
|
||||
assert.Equal(backends[2], backend)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -567,9 +567,8 @@ func TestBackendConfiguration_Etcd(t *testing.T) {
|
|||
assert.Equal(secret3, string(backends[0].secret))
|
||||
}
|
||||
|
||||
if _, found := storage.backends["domain1.invalid"]; found {
|
||||
assert.Fail("Should have removed host information for %s", "domain1.invalid")
|
||||
}
|
||||
_, found := storage.backends["domain1.invalid"]
|
||||
assert.False(found, "Should have removed host information")
|
||||
}
|
||||
|
||||
func TestBackendCommonSecret(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -530,9 +530,9 @@ func RunTestBackendServer_RoomDisinvite(t *testing.T) {
|
|||
}
|
||||
|
||||
if message, err := client.RunUntilMessage(ctx); err != nil && !websocket.IsCloseError(err, websocket.CloseNoStatusReceived) {
|
||||
assert.Fail("Received unexpected error %s", err)
|
||||
assert.NoError(err, "Received unexpected error")
|
||||
} else if err == nil {
|
||||
assert.Fail("Server should have closed the connection, received %+v", *message)
|
||||
assert.Fail("Server should have closed the connection", "received %+v", *message)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -597,7 +597,7 @@ func TestBackendServer_RoomDisinviteDifferentRooms(t *testing.T) {
|
|||
if message, err := client1.RunUntilMessage(ctx); err != nil && !websocket.IsCloseError(err, websocket.CloseNoStatusReceived) {
|
||||
assert.NoError(err)
|
||||
} else if err == nil {
|
||||
assert.Fail("Server should have closed the connection, received %+v", *message)
|
||||
assert.Fail("Server should have closed the connection", "received %+v", *message)
|
||||
}
|
||||
|
||||
if message, err := client2.RunUntilRoomlistDisinvite(ctx); assert.NoError(err) {
|
||||
|
|
@ -1234,7 +1234,7 @@ func TestBackendServer_InCallAll(t *testing.T) {
|
|||
defer cancel2()
|
||||
|
||||
if message, err := client1.RunUntilMessage(ctx2); err == nil {
|
||||
assert.Fail("Expected no message, got %+v", message)
|
||||
assert.Fail("Expected no message", "received %+v", message)
|
||||
} else if err != ErrNoMessageReceived && err != context.DeadlineExceeded {
|
||||
assert.NoError(err)
|
||||
}
|
||||
|
|
@ -1243,7 +1243,7 @@ func TestBackendServer_InCallAll(t *testing.T) {
|
|||
defer cancel3()
|
||||
|
||||
if message, err := client2.RunUntilMessage(ctx3); err == nil {
|
||||
assert.Fail("Expected no message, got %+v", message)
|
||||
assert.Fail("Expected no message", "received %+v", message)
|
||||
} else if err != ErrNoMessageReceived && err != context.DeadlineExceeded {
|
||||
assert.NoError(err)
|
||||
}
|
||||
|
|
@ -1299,7 +1299,7 @@ func TestBackendServer_InCallAll(t *testing.T) {
|
|||
defer cancel4()
|
||||
|
||||
if message, err := client1.RunUntilMessage(ctx4); err == nil {
|
||||
assert.Fail("Expected no message, got %+v", message)
|
||||
assert.Fail("Expected no message", "received %+v", message)
|
||||
} else if err != ErrNoMessageReceived && err != context.DeadlineExceeded {
|
||||
assert.NoError(err)
|
||||
}
|
||||
|
|
@ -1308,7 +1308,7 @@ func TestBackendServer_InCallAll(t *testing.T) {
|
|||
defer cancel5()
|
||||
|
||||
if message, err := client2.RunUntilMessage(ctx5); err == nil {
|
||||
assert.Fail("Expected no message, got %+v", message)
|
||||
assert.Fail("Expected no message", "received %+v", message)
|
||||
} else if err != ErrNoMessageReceived && err != context.DeadlineExceeded {
|
||||
assert.NoError(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -147,13 +147,13 @@ func (r *dnsMonitorReceiver) OnLookup(entry *DnsMonitorEntry, all, add, keep, re
|
|||
expected := r.expected
|
||||
r.expected = nil
|
||||
if expected == expectNone {
|
||||
assert.Fail(r.t, "expected no event, got %v", received)
|
||||
assert.Fail(r.t, "expected no event", "received %v", received)
|
||||
return
|
||||
}
|
||||
|
||||
if expected == nil {
|
||||
if r.received != nil && !r.received.Equal(received) {
|
||||
assert.Fail(r.t, "already received %v, got %v", r.received, received)
|
||||
assert.Fail(r.t, "unexpected message", "already received %v, got %v", r.received, received)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
@ -188,7 +188,7 @@ func (r *dnsMonitorReceiver) Expect(all, add, keep, remove []net.IP) {
|
|||
defer r.Unlock()
|
||||
|
||||
if r.expected != nil && r.expected != expectNone {
|
||||
assert.Fail(r.t, "didn't get previously expected %v", r.expected)
|
||||
assert.Fail(r.t, "didn't get previous message", "expected %v", r.expected)
|
||||
}
|
||||
|
||||
expected := &dnsMonitorReceiverRecord{
|
||||
|
|
@ -211,7 +211,7 @@ func (r *dnsMonitorReceiver) ExpectNone() {
|
|||
defer r.Unlock()
|
||||
|
||||
if r.expected != nil && r.expected != expectNone {
|
||||
assert.Fail(r.t, "didn't get previously expected %v", r.expected)
|
||||
assert.Fail(r.t, "didn't get previous message", "expected %v", r.expected)
|
||||
}
|
||||
|
||||
r.expected = expectNone
|
||||
|
|
|
|||
|
|
@ -172,23 +172,24 @@ func Test_Federation(t *testing.T) {
|
|||
|
||||
request1 := getPingRequests(t)
|
||||
clearPingRequests(t)
|
||||
assert.Len(request1, 1)
|
||||
if ping := request1[0].Ping; assert.NotNil(ping) {
|
||||
assert.Equal(roomId, ping.RoomId)
|
||||
assert.Equal("1.0", ping.Version)
|
||||
assert.Len(ping.Entries, 2)
|
||||
// The order of entries is not defined
|
||||
if ping.Entries[0].SessionId == federatedRoomId+"-"+hello2.Hello.SessionId {
|
||||
assert.Equal(hello2.Hello.UserId, ping.Entries[0].UserId)
|
||||
if assert.Len(request1, 1) {
|
||||
if ping := request1[0].Ping; assert.NotNil(ping) {
|
||||
assert.Equal(roomId, ping.RoomId)
|
||||
assert.Equal("1.0", ping.Version)
|
||||
assert.Len(ping.Entries, 2)
|
||||
// The order of entries is not defined
|
||||
if ping.Entries[0].SessionId == federatedRoomId+"-"+hello2.Hello.SessionId {
|
||||
assert.Equal(hello2.Hello.UserId, ping.Entries[0].UserId)
|
||||
|
||||
assert.Equal(roomId+"-"+hello1.Hello.SessionId, ping.Entries[1].SessionId)
|
||||
assert.Equal(hello1.Hello.UserId, ping.Entries[1].UserId)
|
||||
} else {
|
||||
assert.Equal(roomId+"-"+hello1.Hello.SessionId, ping.Entries[0].SessionId)
|
||||
assert.Equal(hello1.Hello.UserId, ping.Entries[0].UserId)
|
||||
assert.Equal(roomId+"-"+hello1.Hello.SessionId, ping.Entries[1].SessionId)
|
||||
assert.Equal(hello1.Hello.UserId, ping.Entries[1].UserId)
|
||||
} else {
|
||||
assert.Equal(roomId+"-"+hello1.Hello.SessionId, ping.Entries[0].SessionId)
|
||||
assert.Equal(hello1.Hello.UserId, ping.Entries[0].UserId)
|
||||
|
||||
assert.Equal(federatedRoomId+"-"+hello2.Hello.SessionId, ping.Entries[1].SessionId)
|
||||
assert.Equal(hello2.Hello.UserId, ping.Entries[1].UserId)
|
||||
assert.Equal(federatedRoomId+"-"+hello2.Hello.SessionId, ping.Entries[1].SessionId)
|
||||
assert.Equal(hello2.Hello.UserId, ping.Entries[1].UserId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -199,13 +200,14 @@ func Test_Federation(t *testing.T) {
|
|||
|
||||
request2 := getPingRequests(t)
|
||||
clearPingRequests(t)
|
||||
assert.Len(request2, 1)
|
||||
if ping := request2[0].Ping; assert.NotNil(ping) {
|
||||
assert.Equal(federatedRoomId, ping.RoomId)
|
||||
assert.Equal("1.0", ping.Version)
|
||||
assert.Len(ping.Entries, 1)
|
||||
assert.Equal(federatedRoomId+"-"+hello2.Hello.SessionId, ping.Entries[0].SessionId)
|
||||
assert.Equal(hello2.Hello.UserId, ping.Entries[0].UserId)
|
||||
if assert.Len(request2, 1) {
|
||||
if ping := request2[0].Ping; assert.NotNil(ping) {
|
||||
assert.Equal(federatedRoomId, ping.RoomId)
|
||||
assert.Equal("1.0", ping.Version)
|
||||
assert.Len(ping.Entries, 1)
|
||||
assert.Equal(federatedRoomId+"-"+hello2.Hello.SessionId, ping.Entries[0].SessionId)
|
||||
assert.Equal(hello2.Hello.UserId, ping.Entries[0].UserId)
|
||||
}
|
||||
}
|
||||
|
||||
// Leaving and re-joining a room as "direct" session will trigger correct events.
|
||||
|
|
@ -335,7 +337,7 @@ func Test_Federation(t *testing.T) {
|
|||
defer cancel2()
|
||||
|
||||
if message, err := client2.RunUntilMessage(ctx2); err == nil {
|
||||
assert.Fail("expected no message, got %+v", message)
|
||||
assert.Fail("expected no message", "received %+v", message)
|
||||
} else if err != ErrNoMessageReceived && err != context.DeadlineExceeded {
|
||||
assert.NoError(err)
|
||||
}
|
||||
|
|
@ -350,7 +352,7 @@ func Test_Federation(t *testing.T) {
|
|||
defer cancel2()
|
||||
|
||||
if message, err := client2.RunUntilMessage(ctx2); err == nil {
|
||||
assert.Fail("expected no message, got %+v", message)
|
||||
assert.Fail("expected no message", "received %+v", message)
|
||||
} else if err != ErrNoMessageReceived && err != context.DeadlineExceeded {
|
||||
assert.NoError(err)
|
||||
}
|
||||
|
|
|
|||
74
hub_test.go
74
hub_test.go
|
|
@ -281,7 +281,7 @@ func WaitForHub(ctx context.Context, t *testing.T, h *Hub) {
|
|||
h.mu.Lock()
|
||||
h.ru.Lock()
|
||||
dumpGoroutines("", os.Stderr)
|
||||
assert.Fail(t, "Error waiting for clients %+v / rooms %+v / sessions %+v / remoteSessions %v / %d read / %d write to terminate: %s", h.clients, h.rooms, h.sessions, h.remoteSessions, readActive, writeActive, ctx.Err())
|
||||
assert.Fail(t, "Error waiting for hub to terminate", "clients %+v / rooms %+v / sessions %+v / remoteSessions %v / %d read / %d write: %s", h.clients, h.rooms, h.sessions, h.remoteSessions, readActive, writeActive, ctx.Err())
|
||||
h.ru.Unlock()
|
||||
h.mu.Unlock()
|
||||
return
|
||||
|
|
@ -300,11 +300,11 @@ func validateBackendChecksum(t *testing.T, f func(http.ResponseWriter, *http.Req
|
|||
rnd := r.Header.Get(HeaderBackendSignalingRandom)
|
||||
checksum := r.Header.Get(HeaderBackendSignalingChecksum)
|
||||
if rnd == "" || checksum == "" {
|
||||
require.Fail("No checksum headers found in request to %s", r.URL)
|
||||
require.Fail("No checksum headers found", "request to %s", r.URL)
|
||||
}
|
||||
|
||||
if verify := CalculateBackendChecksum(rnd, body, testBackendSecret); verify != checksum {
|
||||
require.Fail("Backend checksum verification failed for request to %s", r.URL)
|
||||
require.Fail("Backend checksum verification failed", "request to %s", r.URL)
|
||||
}
|
||||
|
||||
var request BackendClientRequest
|
||||
|
|
@ -342,7 +342,7 @@ func validateBackendChecksum(t *testing.T, f func(http.ResponseWriter, *http.Req
|
|||
func processAuthRequest(t *testing.T, w http.ResponseWriter, r *http.Request, request *BackendClientRequest) *BackendClientResponse {
|
||||
require := require.New(t)
|
||||
if request.Type != "auth" || request.Auth == nil {
|
||||
require.Fail("Expected an auth backend request, got %+v", request)
|
||||
require.Fail("Expected an auth backend request", "received %+v", request)
|
||||
}
|
||||
|
||||
var params TestBackendClientAuthParams
|
||||
|
|
@ -376,7 +376,7 @@ func processRoomRequest(t *testing.T, w http.ResponseWriter, r *http.Request, re
|
|||
require := require.New(t)
|
||||
assert := assert.New(t)
|
||||
if request.Type != "room" || request.Room == nil {
|
||||
require.Fail("Expected an room backend request, got %+v", request)
|
||||
require.Fail("Expected an room backend request", "received %+v", request)
|
||||
}
|
||||
|
||||
switch request.Room.RoomId {
|
||||
|
|
@ -385,7 +385,7 @@ func processRoomRequest(t *testing.T, w http.ResponseWriter, r *http.Request, re
|
|||
case "test-room-takeover-room-session":
|
||||
// Additional checks for testcase "TestClientTakeoverRoomSession"
|
||||
if request.Room.Action == "leave" && request.Room.UserId == "test-userid1" {
|
||||
assert.Fail("Should not receive \"leave\" event for first user, received %+v", request.Room)
|
||||
assert.Fail("Should not receive \"leave\" event for first user", "received %+v", request.Room)
|
||||
}
|
||||
case "test-invalid-room":
|
||||
response := &BackendClientResponse{
|
||||
|
|
@ -466,7 +466,7 @@ func clearSessionRequestHandler(t *testing.T) { // nolint
|
|||
|
||||
func processSessionRequest(t *testing.T, w http.ResponseWriter, r *http.Request, request *BackendClientRequest) *BackendClientResponse {
|
||||
if request.Type != "session" || request.Session == nil {
|
||||
require.Fail(t, "Expected an session backend request, got %+v", request)
|
||||
require.Fail(t, "Expected an session backend request", "received %+v", request)
|
||||
}
|
||||
|
||||
sessionRequestHander.Lock()
|
||||
|
|
@ -513,7 +513,7 @@ func storePingRequest(t *testing.T, request *BackendClientRequest) {
|
|||
|
||||
func processPingRequest(t *testing.T, w http.ResponseWriter, r *http.Request, request *BackendClientRequest) *BackendClientResponse {
|
||||
if request.Type != "ping" || request.Ping == nil {
|
||||
require.Fail(t, "Expected an ping backend request, got %+v", request)
|
||||
require.Fail(t, "Expected an ping backend request", "received %+v", request)
|
||||
}
|
||||
|
||||
if request.Ping.RoomId == "test-room-with-sessiondata" {
|
||||
|
|
@ -650,7 +650,7 @@ func registerBackendHandlerUrl(t *testing.T, router *mux.Router, url string) {
|
|||
case "ping":
|
||||
return processPingRequest(t, w, r, request)
|
||||
default:
|
||||
require.Fail(t, "Unsupported request received: %+v", request)
|
||||
require.Fail(t, "Unsupported request", "received: %+v", request)
|
||||
return nil
|
||||
}
|
||||
})
|
||||
|
|
@ -784,10 +784,10 @@ func TestWebsocketFeatures(t *testing.T) {
|
|||
}
|
||||
}
|
||||
if len(featuresList) <= 1 {
|
||||
assert.Fail("expected valid features header, got \"%s\"", features)
|
||||
assert.Fail("expected valid features header", "received \"%s\"", features)
|
||||
}
|
||||
_, found := featuresList["hello-v2"]
|
||||
assert.True(found, "expected feature \"hello-v2\", got \"%s\"", features)
|
||||
assert.True(found, "expected feature \"hello-v2\"", "received \"%s\"", features)
|
||||
|
||||
assert.NoError(conn.WriteControl(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, ""), time.Time{}))
|
||||
}
|
||||
|
|
@ -838,7 +838,7 @@ func TestExpectClientHello(t *testing.T) {
|
|||
|
||||
message2, err := client.RunUntilMessage(ctx)
|
||||
if message2 != nil {
|
||||
require.Fail("Received multiple messages, already have %+v, also got %+v", message, message2)
|
||||
require.Fail("Received multiple messages", "already have %+v, also got %+v", message, message2)
|
||||
}
|
||||
require.NoError(checkUnexpectedClose(err))
|
||||
|
||||
|
|
@ -1547,9 +1547,9 @@ func TestClientHelloResumeTakeover(t *testing.T) {
|
|||
}
|
||||
|
||||
if msg, err := client1.RunUntilMessage(ctx); err == nil {
|
||||
assert.Fail("Expected error but received %+v", msg)
|
||||
assert.Fail("Expected error", "received %+v", msg)
|
||||
} else if !websocket.IsCloseError(err, websocket.CloseNormalClosure, websocket.CloseNoStatusReceived) {
|
||||
assert.Fail("Expected close error but received %+v", err)
|
||||
assert.Fail("Expected close error", "received %+v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1897,9 +1897,9 @@ func TestClientHelloResumeProxy_Takeover(t *testing.T) {
|
|||
}
|
||||
|
||||
if msg, err := client1.RunUntilMessage(ctx); err == nil {
|
||||
assert.Fail("Expected error but received %+v", msg)
|
||||
assert.Fail("Expected error", "received %+v", msg)
|
||||
} else if !websocket.IsCloseError(err, websocket.CloseNormalClosure, websocket.CloseNoStatusReceived) {
|
||||
assert.Fail("Expected close error but received %+v", err)
|
||||
assert.Fail("Expected close error", "received %+v", err)
|
||||
}
|
||||
|
||||
client3 := NewTestClient(t, server1, hub1)
|
||||
|
|
@ -1921,9 +1921,9 @@ func TestClientHelloResumeProxy_Takeover(t *testing.T) {
|
|||
}
|
||||
|
||||
if msg, err := client2.RunUntilMessage(ctx); err == nil {
|
||||
assert.Fail("Expected error but received %+v", msg)
|
||||
assert.Fail("Expected error", "received %+v", msg)
|
||||
} else if !websocket.IsCloseError(err, websocket.CloseNormalClosure, websocket.CloseNoStatusReceived) {
|
||||
assert.Fail("Expected close error but received %+v", err)
|
||||
assert.Fail("Expected close error", "received %+v", err)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
@ -2245,7 +2245,7 @@ func TestClientControlMissingPermissions(t *testing.T) {
|
|||
defer cancel2()
|
||||
|
||||
if err := checkReceiveClientMessage(ctx2, client2, "session", hello1.Hello, &payload); err == nil {
|
||||
assert.Fail("Expected no payload, got %+v", payload)
|
||||
assert.Fail("Expected no payload", "received %+v", payload)
|
||||
} else {
|
||||
assert.ErrorIs(err, ErrNoMessageReceived)
|
||||
}
|
||||
|
|
@ -2645,7 +2645,7 @@ func TestClientMessageToCall(t *testing.T) {
|
|||
defer cancel2()
|
||||
|
||||
if message, err := client2.RunUntilMessage(ctx2); err == nil {
|
||||
assert.Fail("Expected no message", "got %+v", message)
|
||||
assert.Fail("Expected no message", "received %+v", message)
|
||||
} else if err != ErrNoMessageReceived && err != context.DeadlineExceeded {
|
||||
assert.NoError(err)
|
||||
}
|
||||
|
|
@ -2766,7 +2766,7 @@ func TestClientControlToCall(t *testing.T) {
|
|||
defer cancel2()
|
||||
|
||||
if message, err := client2.RunUntilMessage(ctx2); err == nil {
|
||||
assert.Fail("Expected no message", "got %+v", message)
|
||||
assert.Fail("Expected no message", "received %+v", message)
|
||||
} else if err != ErrNoMessageReceived && err != context.DeadlineExceeded {
|
||||
assert.NoError(err)
|
||||
}
|
||||
|
|
@ -3008,7 +3008,7 @@ func TestExpectAnonymousJoinRoomAfterLeave(t *testing.T) {
|
|||
defer cancel2()
|
||||
|
||||
if message, err := client.RunUntilMessage(ctx2); err == nil {
|
||||
assert.Fail("Expected no message, got %+v", message)
|
||||
assert.Fail("Expected no message", "received %+v", message)
|
||||
} else if err != ErrNoMessageReceived && err != context.DeadlineExceeded {
|
||||
assert.NoError(err)
|
||||
}
|
||||
|
|
@ -3570,7 +3570,7 @@ func TestClientMessageToSessionIdWhileDisconnected(t *testing.T) {
|
|||
defer cancel2()
|
||||
|
||||
if err := checkReceiveClientMessage(ctx2, client2, "session", hello1.Hello, &payload); err == nil {
|
||||
assert.Fail("Expected no payload, got %+v", payload)
|
||||
assert.Fail("Expected no payload", "received %+v", payload)
|
||||
} else {
|
||||
assert.ErrorIs(err, ErrNoMessageReceived)
|
||||
}
|
||||
|
|
@ -3667,7 +3667,7 @@ func TestRoomParticipantsListUpdateWhileDisconnected(t *testing.T) {
|
|||
defer cancel2()
|
||||
|
||||
if err := checkReceiveClientMessage(ctx2, client2, "session", hello1.Hello, &payload); err == nil {
|
||||
assert.Fail("Expected no payload, got %+v", payload)
|
||||
assert.Fail("Expected no payload", "received %+v", payload)
|
||||
} else {
|
||||
assert.ErrorIs(err, ErrNoMessageReceived)
|
||||
}
|
||||
|
|
@ -3759,9 +3759,9 @@ func RunTestClientTakeoverRoomSession(t *testing.T) {
|
|||
}
|
||||
|
||||
if msg, err := client1.RunUntilMessage(ctx); err == nil {
|
||||
assert.Fail("Expected error but received %+v", msg)
|
||||
assert.Fail("Expected error", "received %+v", msg)
|
||||
} else if !websocket.IsCloseError(err, websocket.CloseNormalClosure, websocket.CloseNoStatusReceived) {
|
||||
assert.Fail("Expected close error but received %+v", err)
|
||||
assert.Fail("Expected close error", "received %+v", err)
|
||||
}
|
||||
|
||||
// The first session has been closed
|
||||
|
|
@ -3777,7 +3777,7 @@ func RunTestClientTakeoverRoomSession(t *testing.T) {
|
|||
defer cancel2()
|
||||
|
||||
if message, err := client2.RunUntilMessage(ctx2); err == nil {
|
||||
assert.Fail("Expected no message, got %+v", message)
|
||||
assert.Fail("Expected no message", "received %+v", message)
|
||||
} else if err != ErrNoMessageReceived && err != context.DeadlineExceeded {
|
||||
assert.NoError(err)
|
||||
}
|
||||
|
|
@ -3890,7 +3890,7 @@ func TestClientSendOfferPermissions(t *testing.T) {
|
|||
defer cancel2()
|
||||
|
||||
if message, err := client1.RunUntilMessage(ctx2); err == nil {
|
||||
assert.Fail("Expected no message, got %+v", message)
|
||||
assert.Fail("Expected no message", "received %+v", message)
|
||||
} else if err != ErrNoMessageReceived && err != context.DeadlineExceeded {
|
||||
assert.NoError(err)
|
||||
}
|
||||
|
|
@ -4359,7 +4359,7 @@ func TestClientRequestOfferNotInRoom(t *testing.T) {
|
|||
defer cancel2()
|
||||
|
||||
if message, err := client2.RunUntilMessage(ctx2); err == nil {
|
||||
assert.Fail("Expected no message, got %+v", message)
|
||||
assert.Fail("Expected no message", "received %+v", message)
|
||||
} else if err != ErrNoMessageReceived && err != context.DeadlineExceeded {
|
||||
assert.NoError(err)
|
||||
}
|
||||
|
|
@ -4416,7 +4416,7 @@ func TestNoSendBetweenSessionsOnDifferentBackends(t *testing.T) {
|
|||
ctx2, cancel2 := context.WithTimeout(context.Background(), 100*time.Millisecond)
|
||||
defer cancel2()
|
||||
if err := checkReceiveClientMessage(ctx2, client1, "session", hello2.Hello, &payload); err == nil {
|
||||
assert.Fail("Expected no payload, got %+v", payload)
|
||||
assert.Fail("Expected no payload", "received %+v", payload)
|
||||
} else {
|
||||
assert.ErrorIs(err, ErrNoMessageReceived)
|
||||
}
|
||||
|
|
@ -4424,7 +4424,7 @@ func TestNoSendBetweenSessionsOnDifferentBackends(t *testing.T) {
|
|||
ctx3, cancel3 := context.WithTimeout(context.Background(), 100*time.Millisecond)
|
||||
defer cancel3()
|
||||
if err := checkReceiveClientMessage(ctx3, client2, "session", hello1.Hello, &payload); err == nil {
|
||||
assert.Fail("Expected no payload, got %+v", payload)
|
||||
assert.Fail("Expected no payload", "received %+v", payload)
|
||||
} else {
|
||||
assert.ErrorIs(err, ErrNoMessageReceived)
|
||||
}
|
||||
|
|
@ -4485,9 +4485,7 @@ func TestNoSameRoomOnDifferentBackends(t *testing.T) {
|
|||
hub.ru.RUnlock()
|
||||
|
||||
if assert.Len(rooms, 2) {
|
||||
if rooms[0].IsEqual(rooms[1]) {
|
||||
assert.Fail("Rooms should be different: %+v", rooms)
|
||||
}
|
||||
assert.False(rooms[0].IsEqual(rooms[1]), "Rooms should be different: %+v", rooms)
|
||||
}
|
||||
|
||||
recipient := MessageClientMessageRecipient{
|
||||
|
|
@ -4503,7 +4501,7 @@ func TestNoSameRoomOnDifferentBackends(t *testing.T) {
|
|||
ctx2, cancel2 := context.WithTimeout(context.Background(), 100*time.Millisecond)
|
||||
defer cancel2()
|
||||
if err := checkReceiveClientMessage(ctx2, client1, "session", hello2.Hello, &payload); err == nil {
|
||||
assert.Fail("Expected no payload, got %+v", payload)
|
||||
assert.Fail("Expected no payload", "received %+v", payload)
|
||||
} else {
|
||||
assert.ErrorIs(err, ErrNoMessageReceived)
|
||||
}
|
||||
|
|
@ -4511,7 +4509,7 @@ func TestNoSameRoomOnDifferentBackends(t *testing.T) {
|
|||
ctx3, cancel3 := context.WithTimeout(context.Background(), 100*time.Millisecond)
|
||||
defer cancel3()
|
||||
if err := checkReceiveClientMessage(ctx3, client2, "session", hello1.Hello, &payload); err == nil {
|
||||
assert.Fail("Expected no payload, got %+v", payload)
|
||||
assert.Fail("Expected no payload", "received %+v", payload)
|
||||
} else {
|
||||
assert.ErrorIs(err, ErrNoMessageReceived)
|
||||
}
|
||||
|
|
@ -4606,7 +4604,7 @@ func TestClientSendOffer(t *testing.T) {
|
|||
defer cancel2()
|
||||
|
||||
if message, err := client1.RunUntilMessage(ctx2); err == nil {
|
||||
assert.Fail("Expected no message, got %+v", message)
|
||||
assert.Fail("Expected no message", "received %+v", message)
|
||||
} else if err != ErrNoMessageReceived && err != context.DeadlineExceeded {
|
||||
assert.NoError(err)
|
||||
}
|
||||
|
|
@ -5322,7 +5320,7 @@ func DoTestSwitchToOne(t *testing.T, details map[string]interface{}) {
|
|||
defer cancel2()
|
||||
|
||||
if message, err := client2.RunUntilMessage(ctx2); err == nil {
|
||||
assert.Fail("Expected no message, got %+v", message)
|
||||
assert.Fail("Expected no message", "received %+v", message)
|
||||
} else if err != ErrNoMessageReceived && err != context.DeadlineExceeded {
|
||||
assert.NoError(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,11 +54,11 @@ func TestGetFmtpValueH264(t *testing.T) {
|
|||
for _, tc := range testcases {
|
||||
value, found := getFmtpValue(tc.fmtp, "profile-level-id")
|
||||
if !found && tc.profile != "" {
|
||||
assert.Fail("did not find profile \"%s\" in \"%s\"", tc.profile, tc.fmtp)
|
||||
assert.Fail("did not find profile", "profile \"%s\" in \"%s\"", tc.profile, tc.fmtp)
|
||||
} else if found && tc.profile == "" {
|
||||
assert.Fail("did not expect profile in \"%s\" but got \"%s\"", tc.fmtp, value)
|
||||
assert.Fail("did not expect profile", "in \"%s\" but got \"%s\"", tc.fmtp, value)
|
||||
} else if found && tc.profile != value {
|
||||
assert.Fail("expected profile \"%s\" in \"%s\" but got \"%s\"", tc.profile, tc.fmtp, value)
|
||||
assert.Fail("expected profile", "profile \"%s\" in \"%s\" but got \"%s\"", tc.profile, tc.fmtp, value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -86,11 +86,11 @@ func TestGetFmtpValueVP9(t *testing.T) {
|
|||
for _, tc := range testcases {
|
||||
value, found := getFmtpValue(tc.fmtp, "profile-id")
|
||||
if !found && tc.profile != "" {
|
||||
assert.Fail("did not find profile \"%s\" in \"%s\"", tc.profile, tc.fmtp)
|
||||
assert.Fail("did not find profile", "profile \"%s\" in \"%s\"", tc.profile, tc.fmtp)
|
||||
} else if found && tc.profile == "" {
|
||||
assert.Fail("did not expect profile in \"%s\" but got \"%s\"", tc.fmtp, value)
|
||||
assert.Fail("did not expect profile", "in \"%s\" but got \"%s\"", tc.fmtp, value)
|
||||
} else if found && tc.profile != value {
|
||||
assert.Fail("expected profile \"%s\" in \"%s\" but got \"%s\"", tc.profile, tc.fmtp, value)
|
||||
assert.Fail("expected profile", "profile \"%s\" in \"%s\" but got \"%s\"", tc.profile, tc.fmtp, value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,9 +106,7 @@ func Test_sortConnectionsForCountry(t *testing.T) {
|
|||
t.Run(country, func(t *testing.T) {
|
||||
sorted := sortConnectionsForCountry(test[0], country, nil)
|
||||
for idx, conn := range sorted {
|
||||
if test[1][idx] != conn {
|
||||
assert.Fail(t, "Index %d for %s: expected %s, got %s", idx, country, test[1][idx].Country(), conn.Country())
|
||||
}
|
||||
assert.Equal(t, test[1][idx], conn, "Index %d for %s: expected %s, got %s", idx, country, test[1][idx].Country(), conn.Country())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -180,9 +178,7 @@ func Test_sortConnectionsForCountryWithOverride(t *testing.T) {
|
|||
t.Run(country, func(t *testing.T) {
|
||||
sorted := sortConnectionsForCountry(test[0], country, continentMap)
|
||||
for idx, conn := range sorted {
|
||||
if test[1][idx] != conn {
|
||||
assert.Fail(t, "Index %d for %s: expected %s, got %s", idx, country, test[1][idx].Country(), conn.Country())
|
||||
}
|
||||
assert.Equal(t, test[1][idx], conn, "Index %d for %s: expected %s, got %s", idx, country, test[1][idx].Country(), conn.Country())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -358,7 +354,7 @@ func (c *testProxyServerClient) handleSendMessageError(fmt string, msg *ProxySer
|
|||
c.t.Helper()
|
||||
|
||||
if !errors.Is(err, websocket.ErrCloseSent) || msg.Type != "event" || msg.Event.Type != "update-load" {
|
||||
assert.Fail(c.t, fmt, msg, err)
|
||||
assert.Fail(c.t, "error while sending message", fmt, msg, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ import (
|
|||
"crypto/x509"
|
||||
"encoding/pem"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
|
|
@ -88,7 +87,7 @@ func WaitForProxyServer(ctx context.Context, t *testing.T, proxy *ProxyServer) {
|
|||
case <-ctx.Done():
|
||||
proxy.clientsLock.Lock()
|
||||
proxy.remoteConnectionsLock.Lock()
|
||||
assert.Fail(t, fmt.Sprintf("Error waiting for clients %+v / sessions %+v / remoteConnections %+v to terminate: %+v", proxy.clients, proxy.sessions, proxy.remoteConnections, ctx.Err()))
|
||||
assert.Fail(t, "Error waiting for proxy to terminate", "clients %+v / sessions %+v / remoteConnections %+v: %+v", proxy.clients, proxy.sessions, proxy.remoteConnections, ctx.Err())
|
||||
proxy.remoteConnectionsLock.Unlock()
|
||||
proxy.clientsLock.Unlock()
|
||||
return
|
||||
|
|
@ -313,7 +312,7 @@ func TestWebsocketFeatures(t *testing.T) {
|
|||
defer conn.Close() // nolint
|
||||
|
||||
if server := response.Header.Get("Server"); !strings.HasPrefix(server, "nextcloud-spreed-signaling-proxy/") {
|
||||
assert.Fail("expected valid server header, got \"%s\"", server)
|
||||
assert.Fail("expected valid server header", "received \"%s\"", server)
|
||||
}
|
||||
features := response.Header.Get("X-Spreed-Signaling-Features")
|
||||
featuresList := make(map[string]bool)
|
||||
|
|
@ -321,14 +320,14 @@ func TestWebsocketFeatures(t *testing.T) {
|
|||
f = strings.TrimSpace(f)
|
||||
if f != "" {
|
||||
if _, found := featuresList[f]; found {
|
||||
assert.Fail("duplicate feature id \"%s\" in \"%s\"", f, features)
|
||||
assert.Fail("duplicate feature", "id \"%s\" in \"%s\"", f, features)
|
||||
}
|
||||
featuresList[f] = true
|
||||
}
|
||||
}
|
||||
assert.NotEmpty(featuresList, "expected valid features header, got \"%s\"", features)
|
||||
if _, found := featuresList["remote-streams"]; !found {
|
||||
assert.Fail("expected feature \"remote-streams\", got \"%s\"", features)
|
||||
assert.Fail("expected feature \"remote-streams\"", "received \"%s\"", features)
|
||||
}
|
||||
|
||||
assert.NoError(conn.WriteControl(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, ""), time.Time{}))
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ func storeKey(t *testing.T, etcd *embed.Etcd, key string, pubkey crypto.PublicKe
|
|||
data, err = x509.MarshalPKIXPublicKey(&pubkey)
|
||||
require.NoError(t, err)
|
||||
default:
|
||||
require.Fail(t, "unknown key type %T in %+v", pubkey, pubkey)
|
||||
require.Fail(t, "unknown key type", "type %T in %+v", pubkey, pubkey)
|
||||
}
|
||||
|
||||
data = pem.EncodeToMemory(&pem.Block{
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ func (p *mcuProxyForConfig) checkEvent(event *proxyConfigEvent) {
|
|||
defer p.mu.Unlock()
|
||||
|
||||
if len(p.expected) == 0 {
|
||||
assert.Fail(p.t, "no event expected, got %+v from %s:%d", event, caller.File, caller.Line)
|
||||
assert.Fail(p.t, "no event expected", "received %+v from %s:%d", event, caller.File, caller.Line)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -145,7 +145,7 @@ func (p *mcuProxyForConfig) checkEvent(event *proxyConfigEvent) {
|
|||
expected := p.expected[0]
|
||||
p.expected = p.expected[1:]
|
||||
if !reflect.DeepEqual(expected, *event) {
|
||||
assert.Fail(p.t, "expected %+v, got %+v from %s:%d", expected, event, caller.File, caller.Line)
|
||||
assert.Fail(p.t, "wrong event", "expected %+v, received %+v from %s:%d", expected, event, caller.File, caller.Line)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ func checkSession(t *testing.T, sessions RoomSessions, sessionId string, roomSes
|
|||
func testRoomSessions(t *testing.T, sessions RoomSessions) {
|
||||
assert := assert.New(t)
|
||||
if sid, err := sessions.GetSessionId("unknown"); err == nil {
|
||||
assert.Fail("Expected error about invalid room session, got session id %s", sid)
|
||||
assert.Fail("Expected error about invalid room session", "got session id %s", sid)
|
||||
} else {
|
||||
assert.ErrorIs(err, ErrNoSuchRoomSession)
|
||||
}
|
||||
|
|
@ -133,7 +133,7 @@ func testRoomSessions(t *testing.T, sessions RoomSessions) {
|
|||
|
||||
sessions.DeleteRoomSession(s1)
|
||||
if sid, err := sessions.GetSessionId("room1"); err == nil {
|
||||
assert.Fail("Expected error about invalid room session, got session id %s", sid)
|
||||
assert.Fail("Expected error about invalid room session", "got session id %s", sid)
|
||||
} else {
|
||||
assert.ErrorIs(err, ErrNoSuchRoomSession)
|
||||
}
|
||||
|
|
@ -150,7 +150,7 @@ func testRoomSessions(t *testing.T, sessions RoomSessions) {
|
|||
|
||||
assert.NoError(sessions.SetRoomSession(s2, "room-session2"))
|
||||
if sid, err := sessions.GetSessionId("room-session"); err == nil {
|
||||
assert.Fail("Expected error about invalid room session, got session id %s", sid)
|
||||
assert.Fail("Expected error about invalid room session", "got session id %s", sid)
|
||||
} else {
|
||||
assert.ErrorIs(err, ErrNoSuchRoomSession)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,11 +46,11 @@ func TestReverseSessionId(t *testing.T) {
|
|||
|
||||
// Invalid base64.
|
||||
if s, err := reverseSessionId("hello world!"); !assert.Error(err) {
|
||||
assert.Fail("should have failed but got %s", s)
|
||||
assert.Fail("should have failed", "received %s", s)
|
||||
}
|
||||
// Invalid base64 length.
|
||||
if s, err := reverseSessionId("123"); !assert.Error(err) {
|
||||
assert.Fail("should have failed but got %s", s)
|
||||
assert.Fail("should have failed", "received %s", s)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -71,9 +71,9 @@ func TestPublicPrivate(t *testing.T) {
|
|||
assert.NotEqual(private, public)
|
||||
|
||||
if data, err := codec.DecodePublic(private); !assert.Error(err) {
|
||||
assert.Fail("should have failed but got %+v", data)
|
||||
assert.Fail("should have failed", "received %+v", data)
|
||||
}
|
||||
if data, err := codec.DecodePrivate(public); !assert.Error(err) {
|
||||
assert.Fail("should have failed but got %+v", data)
|
||||
assert.Fail("should have failed", "received %+v", data)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,8 +41,7 @@ func checkStatsValue(t *testing.T, collector prometheus.Collector, value float64
|
|||
assert := assert.New(t)
|
||||
pc := make([]uintptr, 10)
|
||||
n := runtime.Callers(2, pc)
|
||||
if n == 0 {
|
||||
assert.Fail("Expected value %f for %s, got %f", value, desc, v)
|
||||
if assert.NotEqualValues(0, n, "Expected value %f for %s, got %f", value, desc, v) {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -59,7 +58,7 @@ func checkStatsValue(t *testing.T, collector prometheus.Collector, value float64
|
|||
break
|
||||
}
|
||||
}
|
||||
assert.Fail("Expected value %f for %s, got %f at\n%s", value, desc, v, stack)
|
||||
assert.EqualValues(value, v, "Unexpected value for %s at\n%s", desc, stack)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -72,7 +71,7 @@ func collectAndLint(t *testing.T, collectors ...prometheus.Collector) {
|
|||
}
|
||||
|
||||
for _, problem := range problems {
|
||||
assert.Fail("Problem with %s: %s", problem.Metric, problem.Text)
|
||||
assert.Fail("Problem with metric", "%s: %s", problem.Metric, problem.Text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ func Test_TransientMessages(t *testing.T) {
|
|||
defer cancel2()
|
||||
|
||||
if msg, err := client1.RunUntilMessage(ctx2); err == nil {
|
||||
assert.Fail("Expected no payload, got %+v", msg)
|
||||
assert.Nil(msg, "Expected no payload")
|
||||
} else {
|
||||
require.ErrorIs(err, context.DeadlineExceeded)
|
||||
}
|
||||
|
|
@ -193,7 +193,7 @@ func Test_TransientMessages(t *testing.T) {
|
|||
defer cancel3()
|
||||
|
||||
if msg, err := client1.RunUntilMessage(ctx3); err == nil {
|
||||
assert.Fail("Expected no payload, got %+v", msg)
|
||||
assert.Nil(msg, "Expected no payload")
|
||||
} else {
|
||||
require.ErrorIs(err, context.DeadlineExceeded)
|
||||
}
|
||||
|
|
@ -220,7 +220,7 @@ func Test_TransientMessages(t *testing.T) {
|
|||
} else if len(ignored) == 1 {
|
||||
msg = ignored[0]
|
||||
} else {
|
||||
require.Fail("Received too many messages: %+v", ignored)
|
||||
require.LessOrEqual(len(ignored), 1, "Received too many messages: %+v", ignored)
|
||||
}
|
||||
|
||||
require.NoError(checkMessageTransientInitial(msg, map[string]interface{}{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue