@@ -19,6 +19,7 @@ import (
19
19
"github.com/mongodb/mongo-go-driver/internal/testutil"
20
20
"github.com/mongodb/mongo-go-driver/mongo/aggregateopt"
21
21
"github.com/mongodb/mongo-go-driver/mongo/findopt"
22
+ "github.com/mongodb/mongo-go-driver/mongo/insertopt"
22
23
"github.com/mongodb/mongo-go-driver/mongo/updateopt"
23
24
"github.com/stretchr/testify/assert"
24
25
"github.com/stretchr/testify/require"
@@ -153,9 +154,8 @@ func TestCollection_InsertOne_WriteConcernError(t *testing.T) {
153
154
doc := bson .NewDocument (bson .EC .ObjectID ("_id" , objectid .New ()))
154
155
coll := createTestCollection (t , nil , nil )
155
156
156
- optwc , err := Opt .WriteConcern (writeconcern .New (writeconcern .W (25 )))
157
- require .NoError (t , err )
158
- _ , err = coll .InsertOne (context .Background (), doc , optwc )
157
+ optwc := insertopt .WriteConcern (writeconcern .New (writeconcern .W (25 )))
158
+ _ , err := coll .InsertOne (context .Background (), doc , optwc )
159
159
got , ok := err .(WriteConcernError )
160
160
if ! ok {
161
161
t .Errorf ("Did not receive correct type of error. got %T; want %T" , err , WriteConcernError {})
@@ -254,7 +254,7 @@ func TestCollection_InsertMany_ErrorCases(t *testing.T) {
254
254
require .NoError (t , err )
255
255
256
256
// without option ordered
257
- _ , err = coll .InsertMany (context .Background (), docs , option . OptOrdered (false ))
257
+ _ , err = coll .InsertMany (context .Background (), docs , insertopt . Ordered (false ))
258
258
got , ok := err .(BulkWriteError )
259
259
if ! ok {
260
260
t .Errorf ("Did not receive correct type of error. got %T; want %T" , err , WriteErrors {})
@@ -301,13 +301,8 @@ func TestCollection_InsertMany_ErrorCases(t *testing.T) {
301
301
bson .NewDocument (bson .EC .ObjectID ("_id" , objectid .New ())),
302
302
}
303
303
304
- optwc , err := Opt .WriteConcern (writeconcern .New (writeconcern .W (42 )))
305
- if err != nil {
306
- t .Errorf ("could not create write concern: %+v" , err )
307
- t .FailNow ()
308
- }
309
-
310
- _ , err = coll .InsertMany (context .Background (), docs , optwc )
304
+ optwc := insertopt .WriteConcern (writeconcern .New (writeconcern .W (42 )))
305
+ _ , err := coll .InsertMany (context .Background (), docs , optwc )
311
306
if err == nil {
312
307
t .Errorf ("write concern error not propagated from command: %+v" , err )
313
308
}
@@ -338,9 +333,8 @@ func TestCollection_InsertMany_WriteConcernError(t *testing.T) {
338
333
}
339
334
coll := createTestCollection (t , nil , nil )
340
335
341
- optwc , err := Opt .WriteConcern (writeconcern .New (writeconcern .W (25 )))
342
- require .NoError (t , err )
343
- _ , err = coll .InsertMany (context .Background (), docs , optwc )
336
+ optwc := insertopt .WriteConcern (writeconcern .New (writeconcern .W (25 )))
337
+ _ , err := coll .InsertMany (context .Background (), docs , optwc )
344
338
got , ok := err .(BulkWriteError )
345
339
if ! ok {
346
340
t .Errorf ("Did not receive correct type of error. got %T; want %T\n Error message: %s" , err , BulkWriteError {}, err )
0 commit comments