mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-03 06:38:06 +02:00
Refactor some tests (#34580)
1. use `test.MockVariableValue` as much as possible 2. avoid `time.Sleep` as much as possible
This commit is contained in:
1 parent
c5e78fc7ad
commit
2a1585b32e
23 files changed
+58
-148
No files matched your search
@@ -26,7 +26,8 @@ func (s *testDiscoveredInfo) OpLocalID() string {
|
||||
}
|
||||
|
||||
func TestTimedDiscoveryCache(t *testing.T) {
|
||||
dc := newTimedDiscoveryCache(1 * time.Second)
|
||||
ttl := 50 * time.Millisecond
|
||||
dc := newTimedDiscoveryCache(ttl)
|
||||
|
||||
// Put some initial values
|
||||
dc.Put("foo", &testDiscoveredInfo{}) // openid.opEndpoint: "a", openid.opLocalID: "b", openid.claimedID: "c"})
|
||||
@@ -41,8 +42,8 @@ func TestTimedDiscoveryCache(t *testing.T) {
|
||||
// Attempt to get a non-existent value
|
||||
assert.Nil(t, dc.Get("bar"))
|
||||
|
||||
// Sleep one second and try retrieve again
|
||||
time.Sleep(1 * time.Second)
|
||||
// Sleep for a while and try to retrieve again
|
||||
time.Sleep(ttl * 3 / 2)
|
||||
|
||||
assert.Nil(t, dc.Get("foo"))
|
||||
}
|
||||
Reference in new issue
Block a user