Skip to content

Commit

Permalink
Add regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
gbbr committed Mar 17, 2021
1 parent c3dba0f commit 2443442
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions contrib/globalsign/mgo/mgo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,31 @@ func TestCollection_UpdateId(t *testing.T) {
assert.Equal("mongodb.query", spans[3].OperationName())
}

func TestIssue874(t *testing.T) {
// regression test for DataDog/dd-trace-go#873
assert := assert.New(t)

entity := bson.D{
bson.DocElem{
Name: "entity",
Value: bson.DocElem{
Name: "index",
Value: 0}}}

insert := func(collection *Collection) {
collection.Insert(entity)
var r bson.D
collection.Find(entity).All(&r)
collection.Find(entity).Count()
collection.Find(entity).Explain(&r)
collection.Find(entity).One(&r)
collection.UpdateId(r.Map()["_id"], entity)
}

spans := testMongoCollectionCommand(assert, insert)
assert.Equal(7, len(spans))
}

func TestCollection_Upsert(t *testing.T) {
assert := assert.New(t)

Expand Down

0 comments on commit 2443442

Please sign in to comment.