Skip to content

Commit

Permalink
test(store/event_test): add a test for a full queue
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon Philips committed Dec 22, 2013
1 parent 317b34f commit e1d909e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions store/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,23 @@ func TestScanHistory(t *testing.T) {
t.Fatalf("bad index shoud reuturn nil")
}
}

// TestFullEventQueue tests a queue with capacity = 10
// Add 1000 events into that queue, and test if scanning
// works still for previous events.
func TestFullEventQueue(t *testing.T) {

eh := newEventHistory(10)

// Add
for i := 0; i < 1000; i++ {
e := newEvent(Create, "/foo", uint64(i), uint64(i))
eh.addEvent(e)
e, err := eh.scan("/foo", true, uint64(i-1))
if i > 0 {
if e == nil || err != nil {
t.Fatalf("scan error [/foo] [%v] %v", i-1, i)
}
}
}
}

0 comments on commit e1d909e

Please sign in to comment.