Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump ESModels to 4.0.0 #4

Merged
merged 1 commit into from
Nov 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@

[[constraint]]
name = "github.com/TerrexTech/go-eventspoll"
version = "3.0.0"
version = "4.0.0"

[[constraint]]
name = "github.com/TerrexTech/go-eventstore-models"
version = "3.0.0"
version = "4.0.0"

[[constraint]]
name = "github.com/TerrexTech/go-kafkautils"
Expand Down
10 changes: 5 additions & 5 deletions inventory/inventory_validations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ func TestInventory(t *testing.T) {
var _ = Describe("InventoryAggregate", func() {
Describe("query", func() {
It("should return error if filter is empty", func() {
timeUUID, err := uuuid.NewV1()
uuid, err := uuuid.NewV4()
Expect(err).ToNot(HaveOccurred())
cid, err := uuuid.NewV4()
Expect(err).ToNot(HaveOccurred())
uid, err := uuuid.NewV4()
Expect(err).ToNot(HaveOccurred())

mockEvent := &model.Event{
Action: "delete",
EventAction: "delete",
CorrelationID: cid,
AggregateID: 2,
Data: []byte("{}"),
Timestamp: time.Now(),
NanoTime: time.Now().UnixNano(),
UserUUID: uid,
TimeUUID: timeUUID,
UUID: uuid,
Version: 3,
YearBucket: 2018,
}
Expand All @@ -42,7 +42,7 @@ var _ = Describe("InventoryAggregate", func() {
Expect(kr.CorrelationID).To(Equal(mockEvent.CorrelationID))
Expect(kr.Error).ToNot(BeEmpty())
Expect(kr.ErrorCode).To(Equal(int16(InternalError)))
Expect(kr.UUID).To(Equal(mockEvent.TimeUUID))
Expect(kr.UUID).To(Equal(mockEvent.UUID))
})
})
})
20 changes: 15 additions & 5 deletions inventory/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ func Query(collection *mongo.Collection, event *model.Event) *model.KafkaRespons
CorrelationID: event.CorrelationID,
Error: err.Error(),
ErrorCode: InternalError,
UUID: event.TimeUUID,
EventAction: event.EventAction,
ServiceAction: event.ServiceAction,
UUID: event.UUID,
}
}

Expand All @@ -35,7 +37,9 @@ func Query(collection *mongo.Collection, event *model.Event) *model.KafkaRespons
CorrelationID: event.CorrelationID,
Error: err.Error(),
ErrorCode: InternalError,
UUID: event.TimeUUID,
EventAction: event.EventAction,
ServiceAction: event.ServiceAction,
UUID: event.UUID,
}
}

Expand All @@ -48,7 +52,9 @@ func Query(collection *mongo.Collection, event *model.Event) *model.KafkaRespons
CorrelationID: event.CorrelationID,
Error: err.Error(),
ErrorCode: DatabaseError,
UUID: event.TimeUUID,
EventAction: event.EventAction,
ServiceAction: event.ServiceAction,
UUID: event.UUID,
}
}

Expand All @@ -61,14 +67,18 @@ func Query(collection *mongo.Collection, event *model.Event) *model.KafkaRespons
CorrelationID: event.CorrelationID,
Error: err.Error(),
ErrorCode: InternalError,
UUID: event.TimeUUID,
EventAction: event.EventAction,
ServiceAction: event.ServiceAction,
UUID: event.UUID,
}
}

return &model.KafkaResponse{
AggregateID: event.AggregateID,
CorrelationID: event.CorrelationID,
EventAction: event.EventAction,
Result: resultMarshal,
UUID: event.TimeUUID,
ServiceAction: event.ServiceAction,
UUID: event.UUID,
}
}
2 changes: 1 addition & 1 deletion main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func main() {

for {
select {
case <-eventPoll.RoutinesCtx().Done():
case <-eventPoll.Wait():
err = errors.New("service-context closed")
log.Fatalln(err)

Expand Down
20 changes: 10 additions & 10 deletions test/inventory_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,16 @@ var _ = Describe("InventoryAggregate", func() {
Expect(err).ToNot(HaveOccurred())
uid, err := uuuid.NewV4()
Expect(err).ToNot(HaveOccurred())
timeUUID, err := uuuid.NewV1()
uuid, err := uuuid.NewV4()
Expect(err).ToNot(HaveOccurred())
mockEvent = &model.Event{
Action: "insert",
EventAction: "insert",
CorrelationID: cid,
AggregateID: inventory.AggregateID,
Data: marshalInv,
Timestamp: time.Now(),
NanoTime: time.Now().UnixNano(),
UserUUID: uid,
TimeUUID: timeUUID,
UUID: uuid,
Version: 0,
YearBucket: 2018,
}
Expand All @@ -141,12 +141,12 @@ var _ = Describe("InventoryAggregate", func() {
Expect(err).ToNot(HaveOccurred())

Byf("Creating query MockEvent")
timeUUID, err := uuuid.NewV1()
uuid, err := uuuid.NewV4()
Expect(err).ToNot(HaveOccurred())
mockEvent.Action = "query"
mockEvent.EventAction = "query"
mockEvent.Data = marshalQuery
mockEvent.Timestamp = time.Now()
mockEvent.TimeUUID = timeUUID
mockEvent.NanoTime = time.Now().UnixNano()
mockEvent.UUID = uuid

Byf("Producing MockEvent")
p, err = kafka.NewProducer(&kafka.ProducerConfig{
Expand All @@ -170,11 +170,11 @@ var _ = Describe("InventoryAggregate", func() {
err := json.Unmarshal(msg.Value, kr)
Expect(err).ToNot(HaveOccurred())

if kr.UUID == mockEvent.TimeUUID {
if kr.UUID == mockEvent.UUID {
Expect(kr.Error).To(BeEmpty())
Expect(kr.ErrorCode).To(BeZero())
Expect(kr.CorrelationID).To(Equal(mockEvent.CorrelationID))
Expect(kr.UUID).To(Equal(mockEvent.TimeUUID))
Expect(kr.UUID).To(Equal(mockEvent.UUID))

result := []inventory.Inventory{}
err = json.Unmarshal(kr.Result, &result)
Expand Down