@@ -5,6 +5,7 @@ use serde::{Deserialize, Serialize};
5
5
use crate :: {
6
6
bson:: { doc, Document } ,
7
7
error:: { Error , Result , TRANSIENT_TRANSACTION_ERROR , UNKNOWN_TRANSACTION_COMMIT_RESULT } ,
8
+ options:: { CollectionOptions , WriteConcern } ,
8
9
test:: {
9
10
get_client_options,
10
11
log_uncaptured,
@@ -248,3 +249,32 @@ async fn convenient_api_retry_timeout_commit_transient() {
248
249
let err = result. unwrap_err ( ) ;
249
250
assert ! ( err. contains_label( TRANSIENT_TRANSACTION_ERROR ) ) ;
250
251
}
252
+
253
+ #[ tokio:: test]
254
+ async fn write_concern_not_inherited ( ) {
255
+ if !transactions_supported ( ) . await {
256
+ log_uncaptured ( "Skipping write_concern_not_inherited: no transaction support." ) ;
257
+ return ;
258
+ }
259
+
260
+ let client = Client :: for_test ( ) . await ;
261
+ let db = client. database ( "write_concern_not_inherited" ) ;
262
+ let coll: Collection < Document > = db. collection_with_options (
263
+ "test" ,
264
+ CollectionOptions :: builder ( )
265
+ . write_concern ( WriteConcern :: nodes ( 0 ) )
266
+ . build ( ) ,
267
+ ) ;
268
+ let _ = coll. drop ( ) . write_concern ( WriteConcern :: majority ( ) ) . await ;
269
+ db. create_collection ( coll. name ( ) ) . await . unwrap ( ) ;
270
+
271
+ let mut session = client. start_session ( ) . await . unwrap ( ) ;
272
+ session. start_transaction ( ) . await . unwrap ( ) ;
273
+ coll. insert_one ( doc ! { "n" : 1 } )
274
+ . session ( & mut session)
275
+ . await
276
+ . unwrap ( ) ;
277
+ session. commit_transaction ( ) . await . unwrap ( ) ;
278
+
279
+ assert ! ( coll. find_one( doc! { "n" : 1 } ) . await . unwrap( ) . is_some( ) ) ;
280
+ }
0 commit comments