1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2024-11-25 12:49:51 +01:00
This commit is contained in:
binwiederhier 2023-03-17 22:05:07 -04:00
parent 05d7c65e42
commit 73069ae9a0

View file

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