utils: remove unused methods and constructor from RTTStats (#4672)

This commit is contained in:
Marten Seemann
2024-09-12 15:55:57 +08:00
committed by GitHub
parent 5247a8ee42
commit 7a10ed602d
9 changed files with 60 additions and 140 deletions

View File

@@ -10,40 +10,34 @@ import (
var _ = Describe("Timer", func() {
const d = 10 * time.Millisecond
It("doesn't fire a newly created timer", func() {
It("works correctly for newly created and reset timers", func() {
t := NewTimer()
Consistently(t.Chan()).ShouldNot(Receive())
})
It("works", func() {
t := NewTimer()
t.Reset(time.Now().Add(d))
Eventually(t.Chan()).Should(Receive())
})
It("returns the deadline", func() {
t := NewTimer()
deadline := time.Now().Add(d)
t.Reset(deadline)
Expect(t.Deadline()).To(Equal(deadline))
Eventually(t.Chan()).Should(Receive())
t.SetRead()
t.Reset(time.Now().Add(d))
Eventually(t.Chan()).Should(Receive())
})
It("works multiple times with reading", func() {
It("works multiple times with and without reading", func() {
t := NewTimer()
for i := 0; i < 10; i++ {
t.Reset(time.Now().Add(d))
Eventually(t.Chan()).Should(Receive())
t.SetRead()
}
})
It("works multiple times without reading", func() {
t := NewTimer()
for i := 0; i < 10; i++ {
t.Reset(time.Now().Add(d))
time.Sleep(d * 2)
if i%2 == 0 {
// Read on even iterations
Eventually(t.Chan()).Should(Receive())
t.SetRead()
} else {
// Don't read on odd iterations
time.Sleep(d * 2)
}
}
// Ensure the last timer fires if it wasn't read
Eventually(t.Chan()).Should(Receive())
})