mirror of
https://github.com/binwiederhier/ntfy.git
synced 2024-11-25 12:49:51 +01:00
Fix test
This commit is contained in:
parent
05d7c65e42
commit
73069ae9a0
1 changed files with 9 additions and 2 deletions
|
@ -1186,8 +1186,13 @@ func TestServer_PublishAndExpungeTopicAfter16Hours(t *testing.T) {
|
||||||
"Cache": "no",
|
"Cache": "no",
|
||||||
})
|
})
|
||||||
require.Equal(t, 200, response.Code)
|
require.Equal(t, 200, response.Code)
|
||||||
require.True(t, s.topics["mytopic"].lastAccess.Unix() >= time.Now().Unix()-2)
|
waitFor(t, func() bool {
|
||||||
require.True(t, s.topics["mytopic"].lastAccess.Unix() <= time.Now().Unix()+2)
|
// .lastAccess set in t.Publish() -> t.Keepalive() in Goroutine
|
||||||
|
s.topics["mytopic"].mu.RLock()
|
||||||
|
defer s.topics["mytopic"].mu.RUnlock()
|
||||||
|
return s.topics["mytopic"].lastAccess.Unix() >= time.Now().Unix()-2 &&
|
||||||
|
s.topics["mytopic"].lastAccess.Unix() <= time.Now().Unix()+2
|
||||||
|
})
|
||||||
|
|
||||||
// Topic won't get pruned
|
// Topic won't get pruned
|
||||||
s.execManager()
|
s.execManager()
|
||||||
|
@ -1195,7 +1200,9 @@ func TestServer_PublishAndExpungeTopicAfter16Hours(t *testing.T) {
|
||||||
|
|
||||||
// Fudge with last access, but subscribe, and see that it won't get pruned (because of subscriber)
|
// Fudge with last access, but subscribe, and see that it won't get pruned (because of subscriber)
|
||||||
subID := s.topics["mytopic"].Subscribe(subFn, "", func() {})
|
subID := s.topics["mytopic"].Subscribe(subFn, "", func() {})
|
||||||
|
s.topics["mytopic"].mu.Lock()
|
||||||
s.topics["mytopic"].lastAccess = time.Now().Add(-17 * time.Hour)
|
s.topics["mytopic"].lastAccess = time.Now().Add(-17 * time.Hour)
|
||||||
|
s.topics["mytopic"].mu.Unlock()
|
||||||
s.execManager()
|
s.execManager()
|
||||||
require.NotNil(t, s.topics["mytopic"])
|
require.NotNil(t, s.topics["mytopic"])
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue