Skip to content

Commit

Permalink
store: added missing test case scenerio for scan of de-queued entries
Browse files Browse the repository at this point in the history
Test case added to check err handing for replaced entries.

etcd-io#6255
  • Loading branch information
sinsharat committed Aug 29, 2016
1 parent e53b995 commit 4f150b0
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion store/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@

package store

import "testing"
import (
"testing"

etcdErr "github.com/coreos/etcd/error"
)

// TestEventQueue tests a queue with capacity = 100
// Add 200 events into that queue, and test if the
Expand Down Expand Up @@ -86,6 +90,26 @@ func TestScanHistory(t *testing.T) {
}
}

func TestEventIndexHistoryCleared(t *testing.T) {
eh := newEventHistory(5)

// Add
eh.addEvent(newEvent(Create, "/foo", 1, 1))
eh.addEvent(newEvent(Create, "/foo/bar", 2, 2))
eh.addEvent(newEvent(Create, "/foo/foo", 3, 3))
eh.addEvent(newEvent(Create, "/foo/bar/bar", 4, 4))
eh.addEvent(newEvent(Create, "/foo/foo/foo", 5, 5))

// Add a new event which will replace/de-queue the first entry
eh.addEvent(newEvent(Create, "/foo/bar/bar/bar", 6, 6))

// test for the event which has been replaced.
_, err := eh.scan("/foo", false, 1)
if err == nil || err.ErrorCode != etcdErr.EcodeEventIndexCleared {
t.Fatalf("scan error cleared index should return err with %d got (%v)", etcdErr.EcodeEventIndexCleared, err)
}
}

// TestFullEventQueue tests a queue with capacity = 10
// Add 1000 events into that queue, and test if scanning
// works still for previous events.
Expand Down

0 comments on commit 4f150b0

Please sign in to comment.