mirror of
https://github.com/elyby/chrly.git
synced 2024-11-26 16:51:59 +05:30
Add additional synchronization layer for bath_uuids_provider_test
This commit is contained in:
parent
7f9b60ab3a
commit
a4a9201034
@ -4,6 +4,7 @@ import (
|
|||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -116,7 +117,11 @@ func (suite *batchUuidsProviderTestSuite) SetupTest() {
|
|||||||
suite.iterateChan <- false
|
suite.iterateChan <- false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var lock sync.Mutex
|
||||||
suite.GetUuidAsync = func(username string) chan *batchUuidsProviderGetUuidResult {
|
suite.GetUuidAsync = func(username string) chan *batchUuidsProviderGetUuidResult {
|
||||||
|
lock.Lock()
|
||||||
|
defer lock.Unlock()
|
||||||
|
|
||||||
c := make(chan *batchUuidsProviderGetUuidResult)
|
c := make(chan *batchUuidsProviderGetUuidResult)
|
||||||
s := make(chan int)
|
s := make(chan int)
|
||||||
go func() {
|
go func() {
|
||||||
@ -211,7 +216,7 @@ func (suite *batchUuidsProviderTestSuite) TestGetUuidForMoreThan10Usernames() {
|
|||||||
suite.MojangApi.On("UsernamesToUuids", usernames[0:10]).Once().Return([]*mojang.ProfileInfo{}, nil)
|
suite.MojangApi.On("UsernamesToUuids", usernames[0:10]).Once().Return([]*mojang.ProfileInfo{}, nil)
|
||||||
suite.MojangApi.On("UsernamesToUuids", usernames[10:12]).Once().Return([]*mojang.ProfileInfo{}, nil)
|
suite.MojangApi.On("UsernamesToUuids", usernames[10:12]).Once().Return([]*mojang.ProfileInfo{}, nil)
|
||||||
|
|
||||||
channels := make([]chan *batchUuidsProviderGetUuidResult, 12)
|
channels := make([]chan *batchUuidsProviderGetUuidResult, len(usernames))
|
||||||
for i, username := range usernames {
|
for i, username := range usernames {
|
||||||
channels[i] = suite.GetUuidAsync(username)
|
channels[i] = suite.GetUuidAsync(username)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user