mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
committed by
Derek Collison
parent
09c1acc36c
commit
9214fa2995
@@ -144,17 +144,30 @@ func TestMemStoreAgeLimit(t *testing.T) {
|
||||
if stats.Msgs != uint64(toStore) {
|
||||
t.Fatalf("Expected %d msgs, got %d", toStore, stats.Msgs)
|
||||
}
|
||||
checkExpired := func(t *testing.T) {
|
||||
t.Helper()
|
||||
checkFor(t, time.Second, maxAge, func() error {
|
||||
stats = ms.Stats()
|
||||
if stats.Msgs != 0 {
|
||||
return fmt.Errorf("Expected no msgs, got %d", stats.Msgs)
|
||||
}
|
||||
if stats.Bytes != 0 {
|
||||
return fmt.Errorf("Expected no bytes, got %d", stats.Bytes)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
// Let them expire
|
||||
checkFor(t, time.Second, maxAge, func() error {
|
||||
stats = ms.Stats()
|
||||
if stats.Msgs != 0 {
|
||||
return fmt.Errorf("Expected no msgs, got %d", stats.Msgs)
|
||||
}
|
||||
if stats.Bytes != 0 {
|
||||
return fmt.Errorf("Expected no bytes, got %d", stats.Bytes)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
checkExpired(t)
|
||||
// Now add some more and make sure that timer will fire again.
|
||||
for i := 0; i < toStore; i++ {
|
||||
ms.StoreMsg(subj, msg)
|
||||
}
|
||||
stats = ms.Stats()
|
||||
if stats.Msgs != uint64(toStore) {
|
||||
t.Fatalf("Expected %d msgs, got %d", toStore, stats.Msgs)
|
||||
}
|
||||
checkExpired(t)
|
||||
}
|
||||
|
||||
func TestMemStoreTimeStamps(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user