Skip to content

Commit

Permalink
include parallelismkey in unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-goodisman committed Apr 24, 2024
1 parent 432af6a commit 561931c
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions lib/oplog/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import (
"go.mongodb.org/mongo-driver/bson"
)

// hash of the database name "foo" to be expected for ParallelismKey
const fooHash = -5843589418109203719

// nolint: gocyclo
func TestProcessOplogEntry(t *testing.T) {
// We can't compare raw publications because they contain JSON that can
Expand All @@ -25,9 +28,10 @@ func TestProcessOplogEntry(t *testing.T) {
Fields []string `json:"f"`
}
type decodedPublication struct {
Channels []string
Msg decodedPublicationMessage
OplogTimestamp primitive.Timestamp
Channels []string
Msg decodedPublicationMessage
OplogTimestamp primitive.Timestamp
ParallelismKey int
}

testObjectId, err := primitive.ObjectIDFromHex("deadbeefdeadbeefdeadbeef")
Expand Down Expand Up @@ -67,6 +71,7 @@ func TestProcessOplogEntry(t *testing.T) {
Fields: []string{"some"},
},
OplogTimestamp: primitive.Timestamp{T: 1234},
ParallelismKey: fooHash,
},
},
"Replacement update": {
Expand All @@ -92,6 +97,7 @@ func TestProcessOplogEntry(t *testing.T) {
Fields: []string{"some", "new"},
},
OplogTimestamp: primitive.Timestamp{T: 1234},
ParallelismKey: fooHash,
},
},
"Non-replacement update": {
Expand Down Expand Up @@ -123,6 +129,7 @@ func TestProcessOplogEntry(t *testing.T) {
Fields: []string{"a", "b", "c"},
},
OplogTimestamp: primitive.Timestamp{T: 1234},
ParallelismKey: fooHash,
},
},
"Delete": {
Expand All @@ -145,6 +152,7 @@ func TestProcessOplogEntry(t *testing.T) {
Fields: []string{},
},
OplogTimestamp: primitive.Timestamp{T: 1234},
ParallelismKey: fooHash,
},
},
"ObjectID id": {
Expand Down Expand Up @@ -172,6 +180,7 @@ func TestProcessOplogEntry(t *testing.T) {
Fields: []string{"some"},
},
OplogTimestamp: primitive.Timestamp{T: 1234},
ParallelismKey: fooHash,
},
},
"Unsupported id type": {
Expand Down Expand Up @@ -242,9 +251,10 @@ func TestProcessOplogEntry(t *testing.T) {
sort.Strings(msg.Fields)

return &decodedPublication{
Channels: pub.Channels,
Msg: msg,
OplogTimestamp: pub.OplogTimestamp,
Channels: pub.Channels,
Msg: msg,
OplogTimestamp: pub.OplogTimestamp,
ParallelismKey: pub.ParallelismKey,
}
}

Expand Down

0 comments on commit 561931c

Please sign in to comment.