1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2025-05-25 08:17:36 +02:00
This commit is contained in:
binwiederhier 2023-03-03 22:22:07 -05:00
parent 3eeeac2c13
commit 346d8d7967
8 changed files with 141 additions and 15 deletions

View file

@ -4,6 +4,7 @@ import (
"github.com/stretchr/testify/require"
"sync/atomic"
"testing"
"time"
)
func TestTopic_CancelSubscribers(t *testing.T) {
@ -28,3 +29,13 @@ func TestTopic_CancelSubscribers(t *testing.T) {
require.True(t, canceled1.Load())
require.False(t, canceled2.Load())
}
func TestTopic_Keepalive(t *testing.T) {
t.Parallel()
to := newTopic("mytopic")
to.lastAccess = time.Now().Add(-1 * time.Hour)
to.Keepalive()
require.True(t, to.LastAccess().Unix() >= time.Now().Unix()-2)
require.True(t, to.LastAccess().Unix() <= time.Now().Unix()+2)
}