From a4a92010346d2e85c5cc0a0321dc3600396da141 Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Fri, 3 Jan 2020 01:41:51 +0300 Subject: [PATCH] Add additional synchronization layer for bath_uuids_provider_test --- mojangtextures/batch_uuids_provider_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mojangtextures/batch_uuids_provider_test.go b/mojangtextures/batch_uuids_provider_test.go index e2a614c..24bfc82 100644 --- a/mojangtextures/batch_uuids_provider_test.go +++ b/mojangtextures/batch_uuids_provider_test.go @@ -4,6 +4,7 @@ import ( "crypto/rand" "encoding/base64" "strings" + "sync" "testing" "time" @@ -116,7 +117,11 @@ func (suite *batchUuidsProviderTestSuite) SetupTest() { suite.iterateChan <- false } + var lock sync.Mutex suite.GetUuidAsync = func(username string) chan *batchUuidsProviderGetUuidResult { + lock.Lock() + defer lock.Unlock() + c := make(chan *batchUuidsProviderGetUuidResult) s := make(chan int) 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[10:12]).Once().Return([]*mojang.ProfileInfo{}, nil) - channels := make([]chan *batchUuidsProviderGetUuidResult, 12) + channels := make([]chan *batchUuidsProviderGetUuidResult, len(usernames)) for i, username := range usernames { channels[i] = suite.GetUuidAsync(username) }