Skip to content

Commit 2394253

Browse files
RUST-987 Add index management operations to test runners (#441)
1 parent 3be946f commit 2394253

File tree

12 files changed

+428
-42
lines changed

12 files changed

+428
-42
lines changed

src/coll/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ impl<T> Collection<T> {
598598
/// Lists all indexes on this collection.
599599
pub async fn list_indexes(
600600
&self,
601-
options: impl Into<Option<ListIndexOptions>>,
601+
options: impl Into<Option<ListIndexesOptions>>,
602602
) -> Result<Cursor<IndexModel>> {
603603
let list_indexes = ListIndexes::new(self.namespace(), options.into());
604604
let client = self.client();
@@ -611,7 +611,7 @@ impl<T> Collection<T> {
611611
/// Lists all indexes on this collection using the provided `ClientSession`.
612612
pub async fn list_indexes_with_session(
613613
&self,
614-
options: impl Into<Option<ListIndexOptions>>,
614+
options: impl Into<Option<ListIndexesOptions>>,
615615
session: &mut ClientSession,
616616
) -> Result<SessionCursor<IndexModel>> {
617617
let list_indexes = ListIndexes::new(self.namespace(), options.into());

src/coll/options.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ pub struct DropIndexOptions {
906906
#[serde(rename_all = "camelCase", deny_unknown_fields)]
907907
#[builder(field_defaults(default, setter(into)))]
908908
#[non_exhaustive]
909-
pub struct ListIndexOptions {
909+
pub struct ListIndexesOptions {
910910
/// The maximum amount of time to search for the index.
911911
///
912912
/// This option maps to the `maxTimeMS` MongoDB query option, so the duration will be sent

src/index/options.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,17 @@ pub struct IndexOptions {
120120
#[non_exhaustive]
121121
pub enum IndexVersion {
122122
#[deprecated]
123+
/// Version 0.
123124
V0,
125+
126+
/// Version 1.
124127
V1,
128+
129+
/// Version 2.
125130
V2,
131+
132+
//// Specify a custom index version. This is present to provide forwards compatibility with
133+
/// any future index versions which may be added to new versions of MongoDB.
126134
Custom(u32),
127135
}
128136

@@ -159,9 +167,17 @@ impl<'de> Deserialize<'de> for IndexVersion {
159167
/// Specify the version for a `text` index. For more information, see [Versions](https://docs.mongodb.com/manual/core/index-text/#versions).
160168
#[derive(Clone, Debug)]
161169
pub enum TextIndexVersion {
170+
/// Version 1.
162171
V1,
172+
173+
/// Version 2.
163174
V2,
175+
176+
/// Version 3.
164177
V3,
178+
179+
/// Specify a custom text index version. This is present to provide forwards compatibility with
180+
/// any future text index versions which may be added to new versions of MongoDB.
165181
Custom(u32),
166182
}
167183

@@ -196,8 +212,14 @@ impl<'de> Deserialize<'de> for TextIndexVersion {
196212
/// Specify the version for a `2dsphere` index. For more information, see [Versions](https://docs.mongodb.com/manual/core/2dsphere/#versions).
197213
#[derive(Clone, Debug)]
198214
pub enum Sphere2DIndexVersion {
215+
/// Version 2.
199216
V2,
217+
218+
/// Version 3.
200219
V3,
220+
221+
/// Specify a custom sphere 2D index version. This is present to provide forwards compatibility
222+
/// with any future sphere 2D index verions which may be added to new versions of MongoDB.
201223
Custom(u32),
202224
}
203225

src/lib.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -290,13 +290,8 @@
290290
#![cfg_attr(test, type_length_limit = "80000000")]
291291
#![doc(html_root_url = "https://docs.rs/mongodb/2.0.0-beta.3")]
292292

293-
#[cfg(all(
294-
feature = "aws-auth",
295-
feature = "async-std-runtime"
296-
))]
297-
compile_error!(
298-
"The `aws-auth` feature flag is only supported on the tokio runtime."
299-
);
293+
#[cfg(all(feature = "aws-auth", feature = "async-std-runtime"))]
294+
compile_error!("The `aws-auth` feature flag is only supported on the tokio runtime.");
300295

301296
macro_rules! define_if_single_runtime_enabled {
302297
( $( $def:item )+ ) => {
@@ -352,7 +347,6 @@ define_if_single_runtime_enabled! {
352347
coll::Collection,
353348
cursor::{Cursor, session::{SessionCursor, SessionCursorStream}},
354349
db::Database,
355-
index::IndexModel,
356350
};
357351

358352
#[cfg(feature = "sync")]
@@ -363,7 +357,7 @@ define_if_single_runtime_enabled! {
363357
db::Database,
364358
};
365359

366-
pub use coll::Namespace;
360+
pub use {coll::Namespace, index::IndexModel};
367361
}
368362

369363
#[cfg(all(

src/operation/list_indexes/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::{
55
error::Result,
66
index::IndexModel,
77
operation::{append_options, Operation},
8-
options::ListIndexOptions,
8+
options::ListIndexesOptions,
99
selection_criteria::{ReadPreference, SelectionCriteria},
1010
Namespace,
1111
};
@@ -17,11 +17,11 @@ mod test;
1717

1818
pub(crate) struct ListIndexes {
1919
ns: Namespace,
20-
options: Option<ListIndexOptions>,
20+
options: Option<ListIndexesOptions>,
2121
}
2222

2323
impl ListIndexes {
24-
pub(crate) fn new(ns: Namespace, options: Option<ListIndexOptions>) -> Self {
24+
pub(crate) fn new(ns: Namespace, options: Option<ListIndexesOptions>) -> Self {
2525
ListIndexes { ns, options }
2626
}
2727

src/operation/list_indexes/test.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ use crate::{
44
bson::doc,
55
client::options::ServerAddress,
66
cmap::StreamDescription,
7-
coll::{options::ListIndexOptions, Namespace},
8-
index::{
9-
options::{IndexOptions, IndexVersion, TextIndexVersion},
10-
IndexModel,
11-
},
127
operation::{test::handle_response_test, ListIndexes, Operation},
8+
options::{IndexOptions, IndexVersion, ListIndexesOptions, TextIndexVersion},
9+
IndexModel,
10+
Namespace,
1311
};
1412

1513
#[cfg_attr(feature = "tokio-runtime", tokio::test)]
@@ -20,7 +18,7 @@ async fn build() {
2018
coll: "test_coll".to_string(),
2119
};
2220

23-
let list_options = ListIndexOptions::builder()
21+
let list_options = ListIndexesOptions::builder()
2422
.max_time(Some(Duration::from_millis(42)))
2523
.batch_size(Some(4))
2624
.build();

src/options.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub use crate::{
2121
collation::*,
2222
concern::*,
2323
db::options::*,
24+
index::options::*,
2425
selection_criteria::*,
2526
};
2627

src/sync/coll.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::{
2323
FindOptions,
2424
InsertManyOptions,
2525
InsertOneOptions,
26-
ListIndexOptions,
26+
ListIndexesOptions,
2727
ReadConcern,
2828
ReplaceOptions,
2929
SelectionCriteria,
@@ -416,7 +416,7 @@ impl<T> Collection<T> {
416416
/// Lists all indexes on this collection.
417417
pub fn list_indexes(
418418
&self,
419-
options: impl Into<Option<ListIndexOptions>>,
419+
options: impl Into<Option<ListIndexesOptions>>,
420420
) -> Result<Cursor<IndexModel>> {
421421
RUNTIME
422422
.block_on(self.async_collection.list_indexes(options))
@@ -426,7 +426,7 @@ impl<T> Collection<T> {
426426
/// Lists all indexes on this collection using the provided `ClientSession`.
427427
pub fn list_indexes_with_session(
428428
&self,
429-
options: impl Into<Option<ListIndexOptions>>,
429+
options: impl Into<Option<ListIndexesOptions>>,
430430
session: &mut ClientSession,
431431
) -> Result<SessionCursor<IndexModel>> {
432432
RUNTIME

src/test/spec/unified_runner/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,12 @@ static SPEC_VERSIONS: &[Version] = &[
4242
];
4343

4444
const SKIPPED_OPERATIONS: &[&str] = &[
45-
"assertIndexExists",
46-
"assertIndexNotExists",
4745
"bulkWrite",
4846
"count",
49-
"createIndex",
5047
"download",
5148
"download_by_name",
5249
"listCollectionObjects",
5350
"listDatabaseObjects",
54-
"listIndexNames",
55-
"listIndexes",
5651
"mapReduce",
5752
"watch",
5853
];

0 commit comments

Comments
 (0)