Fix flaky store cooldown test

create-reload-action
Pavel Škoda 6 years ago committed by James Houlahan
parent cc14b523cb
commit 8cdebb6d05
  1. 2
      Changelog.md
  2. 17
      internal/store/cooldown_test.go

@ -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)

@ -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())
}

Loading…
Cancel
Save