mirror of
https://github.com/strukturag/nextcloud-spreed-signaling
synced 2026-03-14 14:35:44 +01:00
Use "testStorage" to store ping requests for parallel access.
This commit is contained in:
parent
e0da0529ec
commit
643c430e36
2 changed files with 13 additions and 16 deletions
24
hub_test.go
24
hub_test.go
|
|
@ -537,30 +537,22 @@ func processSessionRequest(t *testing.T, w http.ResponseWriter, r *http.Request,
|
|||
return response
|
||||
}
|
||||
|
||||
var pingRequests map[*testing.T][]*BackendClientRequest
|
||||
var (
|
||||
pingRequests testStorage[[]*BackendClientRequest]
|
||||
)
|
||||
|
||||
func getPingRequests(t *testing.T) []*BackendClientRequest {
|
||||
return pingRequests[t]
|
||||
entries, _ := pingRequests.Get(t)
|
||||
return entries
|
||||
}
|
||||
|
||||
func clearPingRequests(t *testing.T) {
|
||||
delete(pingRequests, t)
|
||||
pingRequests.Del(t)
|
||||
}
|
||||
|
||||
func storePingRequest(t *testing.T, request *BackendClientRequest) {
|
||||
if entries, found := pingRequests[t]; !found {
|
||||
if pingRequests == nil {
|
||||
pingRequests = make(map[*testing.T][]*BackendClientRequest)
|
||||
}
|
||||
pingRequests[t] = []*BackendClientRequest{
|
||||
request,
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
clearPingRequests(t)
|
||||
})
|
||||
} else {
|
||||
pingRequests[t] = append(entries, request)
|
||||
}
|
||||
entries, _ := pingRequests.Get(t)
|
||||
pingRequests.Set(t, append(entries, request))
|
||||
}
|
||||
|
||||
func processPingRequest(t *testing.T, w http.ResponseWriter, r *http.Request, request *BackendClientRequest) *BackendClientResponse {
|
||||
|
|
|
|||
|
|
@ -196,3 +196,8 @@ func (s *testStorage[T]) Get(t *testing.T) (T, bool) {
|
|||
var defaultValue T
|
||||
return defaultValue, false
|
||||
}
|
||||
|
||||
func (s *testStorage[T]) Del(t *testing.T) {
|
||||
key := t.Name()
|
||||
s.cleanup(key)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue