Beispiel #1
0
func EventStore_Should_not_panic_when_range_is_too_long(t *testing.T, connString string) {
	eventStore, _ := goes.Connect(connString)
	defer eventStore.Close()
	kind := goes.NewAggregateKind("namespace", "kind")
	kindPartition := eventStore.Kind(kind)
	aggregatePartition := kindPartition.Id(1)
	event := Get_Event(1, goes.MAX_EVENT_SIZE)
	aggregatePartition.Put(event)
	aggregatePartition.GetSlice(0, 4)
}
Beispiel #2
0
func EventStore_Should_return_empty_slice_for_new_id(t *testing.T, connString string) {
	// Arrange
	eventStore, _ := goes.Connect(connString)
	defer eventStore.Close()
	kind := goes.NewAggregateKind("namespace", "type")
	kindPartition := eventStore.Kind(kind)
	aggregatePartition := kindPartition.Id(1)

	// Act
	events, _ := aggregatePartition.Get()

	// Assert
	AreEqual(t, 0, events.Count(), "Shouldn't have received any events")
}
Beispiel #3
0
func EventStore_Should_return_single_matching_event_for_existing_id(t *testing.T, connString string) {
	// Arrange
	eventStore, _ := goes.Connect(connString)
	defer eventStore.Close()
	kind := goes.NewAggregateKind("namespace", "type")
	kindPartition := eventStore.Kind(kind)
	aggregatePartition := kindPartition.Id(1)
	event := Get_Event(1, 10)
	aggregatePartition.Put(event)

	// Act
	events, _ := aggregatePartition.Get()

	// Assert
	AreEqual(t, uint16(10), events.LengthAt(0), "Length should have been int32 10")
	AreEqual(t, uint16(1), events.EventTypeAt(0), "EvenType should have been set")
	AreAllEqual(t, event.Data, events.DataAt(0), "Data should have been set")
}
Beispiel #4
0
func Test_Should_put_a_bunch_of_entries(t *testing.T) {
	connString := "mem://"
	eventCount := 100
	kind := goes.NewAggregateKind("namespace", "type")
	event := Get_Event(10, 10)
	i := 0
	index := 0
	for i = 0; i < 1; i++ {
		eventStore, _ := goes.Connect(connString)
		defer eventStore.Close()
		kindPartition := eventStore.Kind(kind)
		aggregatePartition := kindPartition.Id(uint64(i))

		for index = 0; index < eventCount; index++ {
			aggregatePartition.Put(event)

		}
	}
}
Beispiel #5
0
func EventStore_Should_return_middle_events_for_version_range(t *testing.T, connString string) {
	// Arrange
	eventStore, _ := goes.Connect(connString)
	defer eventStore.Close()
	kind := goes.NewAggregateKind("namespace", "kind")
	kindPartition := eventStore.Kind(kind)
	aggregatePartition := kindPartition.Id(1)
	for index := 0; index < 5; index++ {
		event := Get_Event(uint16(index), 10)
		aggregatePartition.Put(event)
	}

	// Act
	events, _ := aggregatePartition.GetSlice(2, 4)

	// Assert
	for index := 0; index < 2; index++ {
		AreEqual(t, uint16(10), events.LengthAt(index), "Length should have been int32 10")
		AreEqual(t, uint16(index+2), events.EventTypeAt(index), "EvenType should have been set")
	}
}