mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-08 07:23:10 -06:00
Close channels
This commit is contained in:
parent
fa3e0b540b
commit
478d34be06
|
|
@ -500,15 +500,18 @@ func TestDeviceListUpdaterIgnoreBlacklisted(t *testing.T) {
|
||||||
userIDToMutex: make(map[string]*sync.Mutex),
|
userIDToMutex: make(map[string]*sync.Mutex),
|
||||||
}
|
}
|
||||||
workerCh := make(chan spec.ServerName)
|
workerCh := make(chan spec.ServerName)
|
||||||
|
defer close(workerCh)
|
||||||
updater.workerChans[0] = workerCh
|
updater.workerChans[0] = workerCh
|
||||||
|
|
||||||
// happy case
|
// happy case
|
||||||
alice := "@alice:localhost"
|
alice := "@alice:localhost"
|
||||||
aliceCh := updater.assignChannel(alice)
|
aliceCh := updater.assignChannel(alice)
|
||||||
|
defer updater.clearChannel(alice)
|
||||||
|
|
||||||
// failing case
|
// failing case
|
||||||
bob := "@bob:" + unreachableServer
|
bob := "@bob:" + unreachableServer
|
||||||
bobCh := updater.assignChannel(string(bob))
|
bobCh := updater.assignChannel(string(bob))
|
||||||
|
defer updater.clearChannel(string(bob))
|
||||||
|
|
||||||
expectedServers := map[spec.ServerName]struct{}{
|
expectedServers := map[spec.ServerName]struct{}{
|
||||||
"localhost": {},
|
"localhost": {},
|
||||||
|
|
@ -521,7 +524,7 @@ func TestDeviceListUpdaterIgnoreBlacklisted(t *testing.T) {
|
||||||
case "localhost":
|
case "localhost":
|
||||||
delete(expectedServers, serverName)
|
delete(expectedServers, serverName)
|
||||||
aliceCh <- true // unblock notifyWorkers
|
aliceCh <- true // unblock notifyWorkers
|
||||||
case "notlocalhost": // this should not happen as it is "filtered" away by the blacklist
|
case unreachableServer: // this should not happen as it is "filtered" away by the blacklist
|
||||||
unexpectedServers[serverName] = struct{}{}
|
unexpectedServers[serverName] = struct{}{}
|
||||||
bobCh <- true
|
bobCh <- true
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue