From d27caa4922d35f99b955c50a9d375e39a21bc672 Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Thu, 21 Nov 2019 19:33:05 +0300 Subject: [PATCH] Add sync channel to batch_uuids_provider_test --- mojangtextures/batch_uuids_provider_test.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mojangtextures/batch_uuids_provider_test.go b/mojangtextures/batch_uuids_provider_test.go index f217dd0..e2a614c 100644 --- a/mojangtextures/batch_uuids_provider_test.go +++ b/mojangtextures/batch_uuids_provider_test.go @@ -118,7 +118,9 @@ func (suite *batchUuidsProviderTestSuite) SetupTest() { suite.GetUuidAsync = func(username string) chan *batchUuidsProviderGetUuidResult { c := make(chan *batchUuidsProviderGetUuidResult) + s := make(chan int) go func() { + s <- 0 profile, err := suite.Provider.GetUuid(username) c <- &batchUuidsProviderGetUuidResult{ Result: profile, @@ -126,6 +128,8 @@ func (suite *batchUuidsProviderTestSuite) SetupTest() { } }() + <-s + return c } @@ -178,9 +182,7 @@ func (suite *batchUuidsProviderTestSuite) TestGetUuidForTwoUsernames() { }, nil) resultChan1 := suite.GetUuidAsync("username1") - time.Sleep(time.Millisecond) // Just to keep order for the usernames resultChan2 := suite.GetUuidAsync("username2") - time.Sleep(time.Millisecond) // Allow to all goroutines begin suite.Iterate() @@ -212,7 +214,6 @@ func (suite *batchUuidsProviderTestSuite) TestGetUuidForMoreThan10Usernames() { channels := make([]chan *batchUuidsProviderGetUuidResult, 12) for i, username := range usernames { channels[i] = suite.GetUuidAsync(username) - time.Sleep(time.Millisecond) // Just to keep order for the usernames } suite.Iterate() @@ -257,9 +258,7 @@ func (suite *batchUuidsProviderTestSuite) TestGetUuidForTwoUsernamesWithAnError( suite.MojangApi.On("UsernamesToUuids", []string{"username1", "username2"}).Once().Return(nil, expectedError) resultChan1 := suite.GetUuidAsync("username1") - time.Sleep(time.Millisecond) // Just to keep order for the usernames resultChan2 := suite.GetUuidAsync("username2") - time.Sleep(time.Millisecond) // Allow to all goroutines begin suite.Iterate()