From 8cdebb6d057f8a1c18cc654f7f4a55ae32d87602 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20=C5=A0koda?= Date: Wed, 27 May 2020 10:06:23 +0200 Subject: [PATCH] Fix flaky store cooldown test --- Changelog.md | 2 ++ internal/store/cooldown_test.go | 17 ++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Changelog.md b/Changelog.md index 767fd60f..a4406dde 100644 --- a/Changelog.md +++ b/Changelog.md @@ -16,6 +16,8 @@ Changelog [format](http://keepachangelog.com/en/1.0.0/) * GODT-390 Don't logout user if AuthRefresh fails because internet was off. * GODT-358 Bad timeouts with Alternative Routing +* GODT-390 Don't logout user if AuthRefresh fails because internet was off +* GODT-341 Fixed flaky unittest for Store synchronization cooldown ## [v1.2.7] Donghai-hotfix - beta (2020-05-07) diff --git a/internal/store/cooldown_test.go b/internal/store/cooldown_test.go index ab454b0c..e8783628 100644 --- a/internal/store/cooldown_test.go +++ b/internal/store/cooldown_test.go @@ -117,17 +117,16 @@ func TestCooldownIncreaseAndReset(t *testing.T) { func TestCooldownNotSooner(t *testing.T) { var testCooldown cooldown waitTime := 100 * time.Millisecond - retries := int64(10) - retryWait := time.Duration(waitTime.Milliseconds()/retries) * time.Millisecond testCooldown.setWaitTimes(waitTime) - // first time it should never be too soon + // First time it should never be too soon. assert.False(t, testCooldown.isTooSoon()) - // these retries should be too soon - for i := retries; i > 0; i-- { - assert.True(t, testCooldown.isTooSoon()) - time.Sleep(retryWait) - } - // after given wait time it shouldn't be soon anymore + + // Only half of given wait time should be too soon. + time.Sleep(waitTime / 2) + assert.True(t, testCooldown.isTooSoon()) + + // After given wait time it shouldn't be soon anymore. + time.Sleep(waitTime / 2) assert.False(t, testCooldown.isTooSoon()) }