fix: Previous sequence (#1086)

* feat: remove previous sequence check

* feat: object creation date

* feat: simplify member write model

* feat: simplify write model

* feat: simplify write model
This commit is contained in:
Fabi
2020-12-14 17:24:01 +01:00
committed by GitHub
parent 5b433dcaa3
commit 7f26f1815b
60 changed files with 229 additions and 693 deletions
+96 -115
View File
@@ -64,10 +64,6 @@ func newTestEvent(description string, data func() interface{}, checkPrevious boo
}
}
func (e *testEvent) CheckPrevious() bool {
return e.shouldCheckPrevious
}
func (e *testEvent) Data() interface{} {
return e.data()
}
@@ -392,15 +388,14 @@ func TestEventstore_aggregatesToEvents(t *testing.T) {
wantErr: false,
events: []*repository.Event{
{
AggregateID: "1",
AggregateType: "test.aggregate",
CheckPreviousSequence: false,
Data: []byte(nil),
EditorService: "editorService",
EditorUser: "editorUser",
ResourceOwner: "ro",
Type: "test.event",
Version: "v1",
AggregateID: "1",
AggregateType: "test.aggregate",
Data: []byte(nil),
EditorService: "editorService",
EditorUser: "editorUser",
ResourceOwner: "ro",
Type: "test.event",
Version: "v1",
},
},
},
@@ -432,26 +427,24 @@ func TestEventstore_aggregatesToEvents(t *testing.T) {
wantErr: false,
events: linkEvents(
&repository.Event{
AggregateID: "1",
AggregateType: "test.aggregate",
CheckPreviousSequence: false,
Data: []byte(nil),
EditorService: "editorService",
EditorUser: "editorUser",
ResourceOwner: "ro",
Type: "test.event",
Version: "v1",
AggregateID: "1",
AggregateType: "test.aggregate",
Data: []byte(nil),
EditorService: "editorService",
EditorUser: "editorUser",
ResourceOwner: "ro",
Type: "test.event",
Version: "v1",
},
&repository.Event{
AggregateID: "1",
AggregateType: "test.aggregate",
CheckPreviousSequence: false,
Data: []byte(nil),
EditorService: "editorService",
EditorUser: "editorUser",
ResourceOwner: "ro",
Type: "test.event",
Version: "v1",
AggregateID: "1",
AggregateType: "test.aggregate",
Data: []byte(nil),
EditorService: "editorService",
EditorUser: "editorUser",
ResourceOwner: "ro",
Type: "test.event",
Version: "v1",
},
),
},
@@ -516,39 +509,36 @@ func TestEventstore_aggregatesToEvents(t *testing.T) {
events: combineEventLists(
linkEvents(
&repository.Event{
AggregateID: "1",
AggregateType: "test.aggregate",
CheckPreviousSequence: false,
Data: []byte(nil),
EditorService: "editorService",
EditorUser: "editorUser",
ResourceOwner: "ro",
Type: "test.event",
Version: "v1",
AggregateID: "1",
AggregateType: "test.aggregate",
Data: []byte(nil),
EditorService: "editorService",
EditorUser: "editorUser",
ResourceOwner: "ro",
Type: "test.event",
Version: "v1",
},
&repository.Event{
AggregateID: "1",
AggregateType: "test.aggregate",
CheckPreviousSequence: false,
Data: []byte(nil),
EditorService: "editorService",
EditorUser: "editorUser",
ResourceOwner: "ro",
Type: "test.event",
Version: "v1",
AggregateID: "1",
AggregateType: "test.aggregate",
Data: []byte(nil),
EditorService: "editorService",
EditorUser: "editorUser",
ResourceOwner: "ro",
Type: "test.event",
Version: "v1",
},
),
[]*repository.Event{
{
AggregateID: "2",
AggregateType: "test.aggregate",
CheckPreviousSequence: true,
Data: []byte(nil),
EditorService: "editorService",
EditorUser: "editorUser",
ResourceOwner: "ro",
Type: "test.event",
Version: "v1",
AggregateID: "2",
AggregateType: "test.aggregate",
Data: []byte(nil),
EditorService: "editorService",
EditorUser: "editorUser",
ResourceOwner: "ro",
Type: "test.event",
Version: "v1",
},
},
),
@@ -661,15 +651,14 @@ func TestEventstore_Push(t *testing.T) {
t: t,
events: []*repository.Event{
{
AggregateID: "1",
AggregateType: "test.aggregate",
CheckPreviousSequence: false,
Data: []byte(nil),
EditorService: "editorService",
EditorUser: "editorUser",
ResourceOwner: "ro",
Type: "test.event",
Version: "v1",
AggregateID: "1",
AggregateType: "test.aggregate",
Data: []byte(nil),
EditorService: "editorService",
EditorUser: "editorUser",
ResourceOwner: "ro",
Type: "test.event",
Version: "v1",
},
},
},
@@ -708,26 +697,24 @@ func TestEventstore_Push(t *testing.T) {
t: t,
events: linkEvents(
&repository.Event{
AggregateID: "1",
AggregateType: "test.aggregate",
CheckPreviousSequence: false,
Data: []byte(nil),
EditorService: "editorService",
EditorUser: "editorUser",
ResourceOwner: "ro",
Type: "test.event",
Version: "v1",
AggregateID: "1",
AggregateType: "test.aggregate",
Data: []byte(nil),
EditorService: "editorService",
EditorUser: "editorUser",
ResourceOwner: "ro",
Type: "test.event",
Version: "v1",
},
&repository.Event{
AggregateID: "1",
AggregateType: "test.aggregate",
CheckPreviousSequence: false,
Data: []byte(nil),
EditorService: "editorService",
EditorUser: "editorUser",
ResourceOwner: "ro",
Type: "test.event",
Version: "v1",
AggregateID: "1",
AggregateType: "test.aggregate",
Data: []byte(nil),
EditorService: "editorService",
EditorUser: "editorUser",
ResourceOwner: "ro",
Type: "test.event",
Version: "v1",
},
),
},
@@ -781,39 +768,36 @@ func TestEventstore_Push(t *testing.T) {
events: combineEventLists(
linkEvents(
&repository.Event{
AggregateID: "1",
AggregateType: "test.aggregate",
CheckPreviousSequence: false,
Data: []byte(nil),
EditorService: "editorService",
EditorUser: "editorUser",
ResourceOwner: "ro",
Type: "test.event",
Version: "v1",
AggregateID: "1",
AggregateType: "test.aggregate",
Data: []byte(nil),
EditorService: "editorService",
EditorUser: "editorUser",
ResourceOwner: "ro",
Type: "test.event",
Version: "v1",
},
&repository.Event{
AggregateID: "1",
AggregateType: "test.aggregate",
CheckPreviousSequence: false,
Data: []byte(nil),
EditorService: "editorService",
EditorUser: "editorUser",
ResourceOwner: "ro",
Type: "test.event",
Version: "v1",
AggregateID: "1",
AggregateType: "test.aggregate",
Data: []byte(nil),
EditorService: "editorService",
EditorUser: "editorUser",
ResourceOwner: "ro",
Type: "test.event",
Version: "v1",
},
),
[]*repository.Event{
{
AggregateID: "2",
AggregateType: "test.aggregate",
CheckPreviousSequence: true,
Data: []byte(nil),
EditorService: "editorService",
EditorUser: "editorUser",
ResourceOwner: "ro",
Type: "test.event",
Version: "v1",
AggregateID: "2",
AggregateType: "test.aggregate",
Data: []byte(nil),
EditorService: "editorService",
EditorUser: "editorUser",
ResourceOwner: "ro",
Type: "test.event",
Version: "v1",
},
},
),
@@ -1335,9 +1319,6 @@ func compareEvents(t *testing.T, want, got *repository.Event) {
if want.AggregateType != got.AggregateType {
t.Errorf("wrong aggregateType got %q want %q", want.AggregateType, got.AggregateType)
}
if want.CheckPreviousSequence != got.CheckPreviousSequence {
t.Errorf("wrong check previous got %v want %v", want.CheckPreviousSequence, got.CheckPreviousSequence)
}
if !reflect.DeepEqual(want.Data, got.Data) {
t.Errorf("wrong data got %s want %s", string(want.Data), string(got.Data))
}