25 lines
564 B
Go
25 lines
564 B
Go
|
|
package handlers
|
||
|
|
|
||
|
|
import (
|
||
|
|
"testing"
|
||
|
|
"time"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestUploadGroupPrunesFailedEntries(t *testing.T) {
|
||
|
|
g := newUploadGrouper()
|
||
|
|
entry := g.entryFor("ip:203.0.113.1|failed")
|
||
|
|
entry.mu.Lock()
|
||
|
|
entry.at = time.Now().Add(-3 * uploadGroupWindow)
|
||
|
|
entry.mu.Unlock()
|
||
|
|
g.lastPrune = time.Now().Add(-uploadGroupPruneInterval)
|
||
|
|
|
||
|
|
_ = g.entryFor("ip:203.0.113.1|next")
|
||
|
|
|
||
|
|
if _, ok := g.entries["ip:203.0.113.1|failed"]; ok {
|
||
|
|
t.Fatalf("stale failed entry was not pruned")
|
||
|
|
}
|
||
|
|
if _, ok := g.entries["ip:203.0.113.1|next"]; !ok {
|
||
|
|
t.Fatalf("new entry was not created")
|
||
|
|
}
|
||
|
|
}
|