Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Don't use the root event ID for the root ID.
Browse files Browse the repository at this point in the history
  • Loading branch information
codahale committed Apr 30, 2014
1 parent 920e144 commit 2418a21
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
6 changes: 3 additions & 3 deletions doc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func Example() {
// "host": "server1.example.com",
// "time": "2014-04-28T13:58:32.201883418-07:00",
// "id": "09c84ee90e7d9b74",
// "root": "09c84ee90e7d9b74",
// "root": "ca2e3c0fdfcf3f5e",
// "schema": "message"
// }
// {
Expand All @@ -35,7 +35,7 @@ func Example() {
// "time": "2014-04-28T13:58:32.202241745-07:00",
// "parent": "09c84ee90e7d9b74",
// "id": "794f8bde67a7f1a7",
// "root": "09c84ee90e7d9b74",
// "root": "ca2e3c0fdfcf3f5e",
// "schema": "message"
// }
// {
Expand All @@ -47,7 +47,7 @@ func Example() {
// "time": "2014-04-28T13:58:32.202257354-07:00",
// "parent": "794f8bde67a7f1a7",
// "id": "33cff19e8bfb7cef",
// "root": "09c84ee90e7d9b74",
// "root": "ca2e3c0fdfcf3f5e",
// "schema": "message"
// }
}
5 changes: 2 additions & 3 deletions event.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ func (id EventID) Format(s string, args ...interface{}) string {
// outside of your system as a whole (e.g., a root event for the first time you
// see a user request).
func NewRootEventID() EventID {
id := generateID()
return EventID{
Root: id,
ID: id,
Root: generateID(),
ID: generateID(),
}
}

Expand Down
10 changes: 7 additions & 3 deletions event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ func TestNewRootEventID(t *testing.T) {
t.Errorf("Zero ID: %+v", id)
}

if id.Root != id.ID {
t.Errorf("Mismatched root: %+v", id)
if id.Root == 0 {
t.Errorf("Zero root: %+v", id)
}

if id.Root == id.ID {
t.Errorf("Duplicate IDs: %+v", id)
}
}

Expand All @@ -35,7 +39,7 @@ func TestNewEventID(t *testing.T) {
t.Errorf("Zero ID: %+v", id)
}

if id.Root != root.ID {
if id.Root != root.Root {
t.Errorf("Mismatched root: %+v", id)
}
}
Expand Down

0 comments on commit 2418a21

Please sign in to comment.