From d7ba9d0aa4a5239ba33fcbb65ed0a0986cfa3abb Mon Sep 17 00:00:00 2001 From: patonw <4967614-patonw@users.noreply.gitlab.com> Date: Wed, 30 Jul 2025 11:48:17 -0700 Subject: [PATCH] Write generated tests to OUT_DIR instead of repo working dir --- build.rs | 15 ++- tests/integration-tests.sh | 2 +- tests/snippet_tests/mod.rs | 50 ------- tests/snippet_tests/test_batch_update.rs | 66 ---------- tests/snippet_tests/test_clear_payload.rs | 22 ---- tests/snippet_tests/test_collection_exists.rs | 15 --- tests/snippet_tests/test_count_points.rs | 25 ---- tests/snippet_tests/test_create_collection.rs | 21 --- .../test_create_collection_with_bq.rs | 28 ---- .../snippet_tests/test_create_field_index.rs | 24 ---- .../test_create_full_snapshot.rs | 15 --- tests/snippet_tests/test_create_shard_key.rs | 24 ---- tests/snippet_tests/test_create_snapshot.rs | 15 --- tests/snippet_tests/test_create_text_index.rs | 33 ----- tests/snippet_tests/test_delete_collection.rs | 15 --- .../snippet_tests/test_delete_field_index.rs | 21 --- .../test_delete_full_snapshot.rs | 15 --- tests/snippet_tests/test_delete_payload.rs | 27 ---- tests/snippet_tests/test_delete_points.rs | 35 ----- tests/snippet_tests/test_delete_shard_key.rs | 22 ---- tests/snippet_tests/test_delete_snapshot.rs | 21 --- tests/snippet_tests/test_delete_vectors.rs | 27 ---- .../test_discover_batch_points.rs | 55 -------- tests/snippet_tests/test_discover_points.rs | 39 ------ tests/snippet_tests/test_facets.rs | 25 ---- tests/snippet_tests/test_get_collection.rs | 15 --- .../test_get_collection_aliases.rs | 15 --- tests/snippet_tests/test_get_collections.rs | 15 --- .../test_get_collections_aliases.rs | 15 --- tests/snippet_tests/test_get_points.rs | 21 --- .../snippet_tests/test_list_full_snapshots.rs | 15 --- tests/snippet_tests/test_list_snapshots.rs | 15 --- tests/snippet_tests/test_overwrite_payload.rs | 34 ----- tests/snippet_tests/test_query_document.rs | 26 ---- tests/snippet_tests/test_query_image.rs | 26 ---- tests/snippet_tests/test_query_points.rs | 122 ------------------ .../snippet_tests/test_query_points_groups.rs | 21 --- .../test_recommend_batch_points.rs | 39 ------ .../test_recommend_point_groups.rs | 24 ---- tests/snippet_tests/test_recommend_points.rs | 30 ----- tests/snippet_tests/test_scroll_points.rs | 27 ---- .../snippet_tests/test_search_batch_points.rs | 31 ----- .../test_search_matrix_offsets.rs | 26 ---- .../snippet_tests/test_search_matrix_pairs.rs | 26 ---- .../snippet_tests/test_search_point_groups.rs | 24 ---- tests/snippet_tests/test_search_points.rs | 25 ---- tests/snippet_tests/test_set_payload.rs | 32 ----- tests/snippet_tests/test_update_aliases.rs | 27 ---- tests/snippet_tests/test_update_collection.rs | 22 ---- tests/snippet_tests/test_update_vectors.rs | 43 ------ tests/snippet_tests/test_upsert_document.rs | 36 ------ tests/snippet_tests/test_upsert_image.rs | 36 ------ tests/snippet_tests/test_upsert_points.rs | 50 ------- tests/test_snippets.rs | 4 +- 54 files changed, 12 insertions(+), 1487 deletions(-) delete mode 100644 tests/snippet_tests/mod.rs delete mode 100644 tests/snippet_tests/test_batch_update.rs delete mode 100644 tests/snippet_tests/test_clear_payload.rs delete mode 100644 tests/snippet_tests/test_collection_exists.rs delete mode 100644 tests/snippet_tests/test_count_points.rs delete mode 100644 tests/snippet_tests/test_create_collection.rs delete mode 100644 tests/snippet_tests/test_create_collection_with_bq.rs delete mode 100644 tests/snippet_tests/test_create_field_index.rs delete mode 100644 tests/snippet_tests/test_create_full_snapshot.rs delete mode 100644 tests/snippet_tests/test_create_shard_key.rs delete mode 100644 tests/snippet_tests/test_create_snapshot.rs delete mode 100644 tests/snippet_tests/test_create_text_index.rs delete mode 100644 tests/snippet_tests/test_delete_collection.rs delete mode 100644 tests/snippet_tests/test_delete_field_index.rs delete mode 100644 tests/snippet_tests/test_delete_full_snapshot.rs delete mode 100644 tests/snippet_tests/test_delete_payload.rs delete mode 100644 tests/snippet_tests/test_delete_points.rs delete mode 100644 tests/snippet_tests/test_delete_shard_key.rs delete mode 100644 tests/snippet_tests/test_delete_snapshot.rs delete mode 100644 tests/snippet_tests/test_delete_vectors.rs delete mode 100644 tests/snippet_tests/test_discover_batch_points.rs delete mode 100644 tests/snippet_tests/test_discover_points.rs delete mode 100644 tests/snippet_tests/test_facets.rs delete mode 100644 tests/snippet_tests/test_get_collection.rs delete mode 100644 tests/snippet_tests/test_get_collection_aliases.rs delete mode 100644 tests/snippet_tests/test_get_collections.rs delete mode 100644 tests/snippet_tests/test_get_collections_aliases.rs delete mode 100644 tests/snippet_tests/test_get_points.rs delete mode 100644 tests/snippet_tests/test_list_full_snapshots.rs delete mode 100644 tests/snippet_tests/test_list_snapshots.rs delete mode 100644 tests/snippet_tests/test_overwrite_payload.rs delete mode 100644 tests/snippet_tests/test_query_document.rs delete mode 100644 tests/snippet_tests/test_query_image.rs delete mode 100644 tests/snippet_tests/test_query_points.rs delete mode 100644 tests/snippet_tests/test_query_points_groups.rs delete mode 100644 tests/snippet_tests/test_recommend_batch_points.rs delete mode 100644 tests/snippet_tests/test_recommend_point_groups.rs delete mode 100644 tests/snippet_tests/test_recommend_points.rs delete mode 100644 tests/snippet_tests/test_scroll_points.rs delete mode 100644 tests/snippet_tests/test_search_batch_points.rs delete mode 100644 tests/snippet_tests/test_search_matrix_offsets.rs delete mode 100644 tests/snippet_tests/test_search_matrix_pairs.rs delete mode 100644 tests/snippet_tests/test_search_point_groups.rs delete mode 100644 tests/snippet_tests/test_search_points.rs delete mode 100644 tests/snippet_tests/test_set_payload.rs delete mode 100644 tests/snippet_tests/test_update_aliases.rs delete mode 100644 tests/snippet_tests/test_update_collection.rs delete mode 100644 tests/snippet_tests/test_update_vectors.rs delete mode 100644 tests/snippet_tests/test_upsert_document.rs delete mode 100644 tests/snippet_tests/test_upsert_image.rs delete mode 100644 tests/snippet_tests/test_upsert_points.rs diff --git a/build.rs b/build.rs index 1c917e58..2723f99b 100644 --- a/build.rs +++ b/build.rs @@ -1,7 +1,7 @@ -use std::fs; use std::path::{Path, PathBuf}; +use std::{env, fs}; -fn generate_snippet_test(snippet: &str, name: &str, dir: &Path) { +fn generate_snippet_test(snippet: &str, name: &str, dir: impl AsRef) { // Pad each line of the snippet with 8 spaces let snippet = snippet @@ -26,7 +26,7 @@ async fn test_{name}() {{ ); // Write the test snippet to the file - let mut test_snippet_path = PathBuf::from(dir); + let mut test_snippet_path = PathBuf::from(dir.as_ref()); test_snippet_path.push(format!("test_{name}.rs")); fs::write(test_snippet_path, test_snippet).unwrap(); } @@ -37,14 +37,15 @@ fn main() { #[cfg(not(feature = "generate-snippets"))] return; + let out_dir = env::var_os("OUT_DIR").unwrap(); // Open all files in the `./tests/snippets` directory and save them to the `./tests/snippets_converted` directory // Wrap text in the `tests/test_snippets.rs` file into { } let snippets_dir = Path::new("./tests/snippets"); - let tests_output_dir = Path::new("./tests/snippet_tests"); + let tests_output_dir = Path::new(&out_dir).join("tests/snippet_tests"); // Create the converted directory if it doesn't exist if !tests_output_dir.exists() { - fs::create_dir_all(tests_output_dir).unwrap(); + fs::create_dir_all(&tests_output_dir).unwrap(); } let mut snippet_names: Vec<_> = fs::read_dir(snippets_dir) @@ -65,7 +66,7 @@ fn main() { for (path, name) in &snippet_names { let content = fs::read_to_string(path).unwrap(); - generate_snippet_test(&content, name, tests_output_dir); + generate_snippet_test(&content, name, &tests_output_dir); } // Generate `tests/snippet_tests/mod.rs` file @@ -77,7 +78,7 @@ fn main() { .collect::>() .join("\n"); - let mut mod_file_path = PathBuf::from(tests_output_dir); + let mut mod_file_path = PathBuf::from(&tests_output_dir); mod_file_path.push("mod.rs"); fs::write(mod_file_path, mod_file).unwrap(); } diff --git a/tests/integration-tests.sh b/tests/integration-tests.sh index 6e8c77a8..1e493c84 100755 --- a/tests/integration-tests.sh +++ b/tests/integration-tests.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -ex diff --git a/tests/snippet_tests/mod.rs b/tests/snippet_tests/mod.rs deleted file mode 100644 index 828222a8..00000000 --- a/tests/snippet_tests/mod.rs +++ /dev/null @@ -1,50 +0,0 @@ -mod test_batch_update; -mod test_clear_payload; -mod test_collection_exists; -mod test_count_points; -mod test_create_collection; -mod test_create_collection_with_bq; -mod test_create_field_index; -mod test_create_full_snapshot; -mod test_create_shard_key; -mod test_create_snapshot; -mod test_create_text_index; -mod test_delete_collection; -mod test_delete_field_index; -mod test_delete_full_snapshot; -mod test_delete_payload; -mod test_delete_points; -mod test_delete_shard_key; -mod test_delete_snapshot; -mod test_delete_vectors; -mod test_discover_batch_points; -mod test_discover_points; -mod test_facets; -mod test_get_collection; -mod test_get_collection_aliases; -mod test_get_collections; -mod test_get_collections_aliases; -mod test_get_points; -mod test_list_full_snapshots; -mod test_list_snapshots; -mod test_overwrite_payload; -mod test_query_document; -mod test_query_image; -mod test_query_points; -mod test_query_points_groups; -mod test_recommend_batch_points; -mod test_recommend_point_groups; -mod test_recommend_points; -mod test_scroll_points; -mod test_search_batch_points; -mod test_search_matrix_offsets; -mod test_search_matrix_pairs; -mod test_search_point_groups; -mod test_search_points; -mod test_set_payload; -mod test_update_aliases; -mod test_update_collection; -mod test_update_vectors; -mod test_upsert_document; -mod test_upsert_image; -mod test_upsert_points; \ No newline at end of file diff --git a/tests/snippet_tests/test_batch_update.rs b/tests/snippet_tests/test_batch_update.rs deleted file mode 100644 index c31c636a..00000000 --- a/tests/snippet_tests/test_batch_update.rs +++ /dev/null @@ -1,66 +0,0 @@ - -#[tokio::test] -async fn test_batch_update() { - async fn batch_update() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/batch_update.rs` file - use qdrant_client::qdrant::{ - points_selector::PointsSelectorOneOf, - points_update_operation::{ - Operation, OverwritePayload, PointStructList, UpdateVectors, - }, - PointStruct, PointVectors, PointsIdsList, PointsSelector, PointsUpdateOperation, - UpdateBatchPointsBuilder, - }; - use qdrant_client::{Qdrant, Payload}; - use serde_json::json; - use std::collections::HashMap; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client - .update_points_batch( - UpdateBatchPointsBuilder::new( - "{collection_name}", - vec![ - PointsUpdateOperation { - operation: Some(Operation::Upsert(PointStructList { - points: vec![PointStruct::new( - 1, - vec![1.0, 2.0, 3.0, 4.0], - Payload::try_from(json!({})).unwrap(), - )], - ..Default::default() - })), - }, - PointsUpdateOperation { - operation: Some(Operation::UpdateVectors(UpdateVectors { - points: vec![PointVectors { - id: Some(1.into()), - vectors: Some(vec![1.0, 2.0, 3.0, 4.0].into()), - }], - ..Default::default() - })), - }, - PointsUpdateOperation { - operation: Some(Operation::OverwritePayload(OverwritePayload { - points_selector: Some(PointsSelector { - points_selector_one_of: Some(PointsSelectorOneOf::Points( - PointsIdsList { - ids: vec![1.into()], - }, - )), - }), - payload: HashMap::from([("test_payload".to_string(), 1.into())]), - ..Default::default() - })), - }, - ], - ) - .wait(true), - ) - .await?; - Ok(()) - } - let _ = batch_update().await; -} diff --git a/tests/snippet_tests/test_clear_payload.rs b/tests/snippet_tests/test_clear_payload.rs deleted file mode 100644 index f0a0e812..00000000 --- a/tests/snippet_tests/test_clear_payload.rs +++ /dev/null @@ -1,22 +0,0 @@ - -#[tokio::test] -async fn test_clear_payload() { - async fn clear_payload() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/clear_payload.rs` file - use qdrant_client::qdrant::{ClearPayloadPointsBuilder, PointsIdsList}; - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client - .clear_payload(ClearPayloadPointsBuilder::new("{collection_name}").points( - PointsIdsList { - ids: vec![0.into(), 3.into(), 100.into()], - }, - )) - .await?; - Ok(()) - } - let _ = clear_payload().await; -} diff --git a/tests/snippet_tests/test_collection_exists.rs b/tests/snippet_tests/test_collection_exists.rs deleted file mode 100644 index d5011f80..00000000 --- a/tests/snippet_tests/test_collection_exists.rs +++ /dev/null @@ -1,15 +0,0 @@ - -#[tokio::test] -async fn test_collection_exists() { - async fn collection_exists() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/collection_exists.rs` file - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client.collection_exists("{collection_name}").await?; - Ok(()) - } - let _ = collection_exists().await; -} diff --git a/tests/snippet_tests/test_count_points.rs b/tests/snippet_tests/test_count_points.rs deleted file mode 100644 index b5a2e3b5..00000000 --- a/tests/snippet_tests/test_count_points.rs +++ /dev/null @@ -1,25 +0,0 @@ - -#[tokio::test] -async fn test_count_points() { - async fn count_points() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/count_points.rs` file - use qdrant_client::qdrant::{Condition, CountPointsBuilder, Filter}; - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client - .count( - CountPointsBuilder::new("{collection_name}") - .filter(Filter::must([Condition::matches( - "color", - "red".to_string(), - )])) - .exact(true), - ) - .await?; - Ok(()) - } - let _ = count_points().await; -} diff --git a/tests/snippet_tests/test_create_collection.rs b/tests/snippet_tests/test_create_collection.rs deleted file mode 100644 index cd22542d..00000000 --- a/tests/snippet_tests/test_create_collection.rs +++ /dev/null @@ -1,21 +0,0 @@ - -#[tokio::test] -async fn test_create_collection() { - async fn create_collection() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/create_collection.rs` file - use qdrant_client::qdrant::{CreateCollectionBuilder, Distance, VectorParamsBuilder}; - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client - .create_collection( - CreateCollectionBuilder::new("{collection_name}") - .vectors_config(VectorParamsBuilder::new(100, Distance::Cosine)), - ) - .await?; - Ok(()) - } - let _ = create_collection().await; -} diff --git a/tests/snippet_tests/test_create_collection_with_bq.rs b/tests/snippet_tests/test_create_collection_with_bq.rs deleted file mode 100644 index 1487cdc3..00000000 --- a/tests/snippet_tests/test_create_collection_with_bq.rs +++ /dev/null @@ -1,28 +0,0 @@ - -#[tokio::test] -async fn test_create_collection_with_bq() { - async fn create_collection_with_bq() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/create_collection_with_bq.rs` file - use qdrant_client::qdrant::{ - BinaryQuantizationBuilder, BinaryQuantizationEncoding, CreateCollectionBuilder, Distance, VectorParamsBuilder, BinaryQuantizationQueryEncoding, - }; - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client - .create_collection( - CreateCollectionBuilder::new("{collection_name}") - .vectors_config(VectorParamsBuilder::new(1536, Distance::Cosine)) - .quantization_config( - BinaryQuantizationBuilder::new(true) - .encoding(BinaryQuantizationEncoding::TwoBits) - .query_encoding(BinaryQuantizationQueryEncoding::scalar8bits()) - ), - ) - .await?; - Ok(()) - } - let _ = create_collection_with_bq().await; -} diff --git a/tests/snippet_tests/test_create_field_index.rs b/tests/snippet_tests/test_create_field_index.rs deleted file mode 100644 index 0e296758..00000000 --- a/tests/snippet_tests/test_create_field_index.rs +++ /dev/null @@ -1,24 +0,0 @@ - -#[tokio::test] -async fn test_create_field_index() { - async fn create_field_index() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/create_field_index.rs` file - use qdrant_client::qdrant::{CreateFieldIndexCollectionBuilder, FieldType}; - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client - .create_field_index( - CreateFieldIndexCollectionBuilder::new( - "{collection_name}", - "{field_name}", - FieldType::Keyword, - ), - ) - .await?; - Ok(()) - } - let _ = create_field_index().await; -} diff --git a/tests/snippet_tests/test_create_full_snapshot.rs b/tests/snippet_tests/test_create_full_snapshot.rs deleted file mode 100644 index 70943d20..00000000 --- a/tests/snippet_tests/test_create_full_snapshot.rs +++ /dev/null @@ -1,15 +0,0 @@ - -#[tokio::test] -async fn test_create_full_snapshot() { - async fn create_full_snapshot() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/create_full_snapshot.rs` file - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client.create_full_snapshot().await?; - Ok(()) - } - let _ = create_full_snapshot().await; -} diff --git a/tests/snippet_tests/test_create_shard_key.rs b/tests/snippet_tests/test_create_shard_key.rs deleted file mode 100644 index 52fcc842..00000000 --- a/tests/snippet_tests/test_create_shard_key.rs +++ /dev/null @@ -1,24 +0,0 @@ - -#[tokio::test] -async fn test_create_shard_key() { - async fn create_shard_key() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/create_shard_key.rs` file - use qdrant_client::qdrant::shard_key::Key; - use qdrant_client::qdrant::{CreateShardKeyBuilder, CreateShardKeyRequestBuilder}; - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client - .create_shard_key( - CreateShardKeyRequestBuilder::new("{collection_name}").request( - CreateShardKeyBuilder::default() - .shard_key(Key::Keyword("{shard_key}".to_string())), - ), - ) - .await?; - Ok(()) - } - let _ = create_shard_key().await; -} diff --git a/tests/snippet_tests/test_create_snapshot.rs b/tests/snippet_tests/test_create_snapshot.rs deleted file mode 100644 index 464484ff..00000000 --- a/tests/snippet_tests/test_create_snapshot.rs +++ /dev/null @@ -1,15 +0,0 @@ - -#[tokio::test] -async fn test_create_snapshot() { - async fn create_snapshot() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/create_snapshot.rs` file - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client.create_snapshot("{collection_name}").await?; - Ok(()) - } - let _ = create_snapshot().await; -} diff --git a/tests/snippet_tests/test_create_text_index.rs b/tests/snippet_tests/test_create_text_index.rs deleted file mode 100644 index 433647ef..00000000 --- a/tests/snippet_tests/test_create_text_index.rs +++ /dev/null @@ -1,33 +0,0 @@ - -#[tokio::test] -async fn test_create_text_index() { - async fn create_text_index() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/create_text_index.rs` file - use qdrant_client::qdrant::{ - CreateFieldIndexCollectionBuilder, - TextIndexParamsBuilder, - FieldType, - TokenizerType, - }; - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - let text_index_params = TextIndexParamsBuilder::new(TokenizerType::Word) - .phrase_matching(true) - .lowercase(true); - - client - .create_field_index( - CreateFieldIndexCollectionBuilder::new( - "{collection_name}", - "{field_name}", - FieldType::Text, - ).field_index_params(text_index_params.build()), - ) - .await?; - Ok(()) - } - let _ = create_text_index().await; -} diff --git a/tests/snippet_tests/test_delete_collection.rs b/tests/snippet_tests/test_delete_collection.rs deleted file mode 100644 index cb159b23..00000000 --- a/tests/snippet_tests/test_delete_collection.rs +++ /dev/null @@ -1,15 +0,0 @@ - -#[tokio::test] -async fn test_delete_collection() { - async fn delete_collection() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/delete_collection.rs` file - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client.delete_collection("{collection_name}").await?; - Ok(()) - } - let _ = delete_collection().await; -} diff --git a/tests/snippet_tests/test_delete_field_index.rs b/tests/snippet_tests/test_delete_field_index.rs deleted file mode 100644 index 8e53a7d9..00000000 --- a/tests/snippet_tests/test_delete_field_index.rs +++ /dev/null @@ -1,21 +0,0 @@ - -#[tokio::test] -async fn test_delete_field_index() { - async fn delete_field_index() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/delete_field_index.rs` file - use qdrant_client::qdrant::DeleteFieldIndexCollectionBuilder; - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client - .delete_field_index(DeleteFieldIndexCollectionBuilder::new( - "{collection_name}", - "{field_name}", - )) - .await?; - Ok(()) - } - let _ = delete_field_index().await; -} diff --git a/tests/snippet_tests/test_delete_full_snapshot.rs b/tests/snippet_tests/test_delete_full_snapshot.rs deleted file mode 100644 index 8aaa9727..00000000 --- a/tests/snippet_tests/test_delete_full_snapshot.rs +++ /dev/null @@ -1,15 +0,0 @@ - -#[tokio::test] -async fn test_delete_full_snapshot() { - async fn delete_full_snapshot() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/delete_full_snapshot.rs` file - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client.delete_full_snapshot("{snapshot_name}").await?; - Ok(()) - } - let _ = delete_full_snapshot().await; -} diff --git a/tests/snippet_tests/test_delete_payload.rs b/tests/snippet_tests/test_delete_payload.rs deleted file mode 100644 index ae32c741..00000000 --- a/tests/snippet_tests/test_delete_payload.rs +++ /dev/null @@ -1,27 +0,0 @@ - -#[tokio::test] -async fn test_delete_payload() { - async fn delete_payload() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/delete_payload.rs` file - use qdrant_client::qdrant::{DeletePayloadPointsBuilder, PointsIdsList}; - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client - .delete_payload( - DeletePayloadPointsBuilder::new( - "{collection_name}", - vec!["color".to_string(), "price".to_string()], - ) - .points_selector(PointsIdsList { - ids: vec![0.into(), 3.into(), 100.into()], - }) - .wait(true), - ) - .await?; - Ok(()) - } - let _ = delete_payload().await; -} diff --git a/tests/snippet_tests/test_delete_points.rs b/tests/snippet_tests/test_delete_points.rs deleted file mode 100644 index 4b41850c..00000000 --- a/tests/snippet_tests/test_delete_points.rs +++ /dev/null @@ -1,35 +0,0 @@ - -#[tokio::test] -async fn test_delete_points() { - async fn delete_points() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/delete_points.rs` file - use qdrant_client::qdrant::{Condition, DeletePointsBuilder, Filter, PointsIdsList}; - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client - .delete_points( - DeletePointsBuilder::new("{collection_name}") - .points(PointsIdsList { - ids: vec![0.into(), 3.into(), 100.into()], - }) - .wait(true), - ) - .await?; - - client - .delete_points( - DeletePointsBuilder::new("{collection_name}") - .points(Filter::must([Condition::matches( - "color", - "red".to_string(), - )])) - .wait(true), - ) - .await?; - Ok(()) - } - let _ = delete_points().await; -} diff --git a/tests/snippet_tests/test_delete_shard_key.rs b/tests/snippet_tests/test_delete_shard_key.rs deleted file mode 100644 index fa0cabfa..00000000 --- a/tests/snippet_tests/test_delete_shard_key.rs +++ /dev/null @@ -1,22 +0,0 @@ - -#[tokio::test] -async fn test_delete_shard_key() { - async fn delete_shard_key() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/delete_shard_key.rs` file - use qdrant_client::qdrant::shard_key::Key; - use qdrant_client::qdrant::DeleteShardKeyRequestBuilder; - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client - .delete_shard_key( - DeleteShardKeyRequestBuilder::new("{collection_name}") - .key(Key::Keyword("{shard_key}".to_string())), - ) - .await?; - Ok(()) - } - let _ = delete_shard_key().await; -} diff --git a/tests/snippet_tests/test_delete_snapshot.rs b/tests/snippet_tests/test_delete_snapshot.rs deleted file mode 100644 index c16e9e99..00000000 --- a/tests/snippet_tests/test_delete_snapshot.rs +++ /dev/null @@ -1,21 +0,0 @@ - -#[tokio::test] -async fn test_delete_snapshot() { - async fn delete_snapshot() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/delete_snapshot.rs` file - use qdrant_client::qdrant::DeleteSnapshotRequestBuilder; - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client - .delete_snapshot(DeleteSnapshotRequestBuilder::new( - "{collection_name}", - "{snapshot_name}", - )) - .await?; - Ok(()) - } - let _ = delete_snapshot().await; -} diff --git a/tests/snippet_tests/test_delete_vectors.rs b/tests/snippet_tests/test_delete_vectors.rs deleted file mode 100644 index 1564b83d..00000000 --- a/tests/snippet_tests/test_delete_vectors.rs +++ /dev/null @@ -1,27 +0,0 @@ - -#[tokio::test] -async fn test_delete_vectors() { - async fn delete_vectors() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/delete_vectors.rs` file - use qdrant_client::qdrant::{DeletePointVectorsBuilder, PointsIdsList, VectorsSelector}; - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client - .delete_vectors( - DeletePointVectorsBuilder::new("{collection_name}") - .points_selector(PointsIdsList { - ids: vec![0.into(), 3.into(), 10.into()], - }) - .vectors(VectorsSelector { - names: vec!["text".into(), "image".into()], - }) - .wait(true), - ) - .await?; - Ok(()) - } - let _ = delete_vectors().await; -} diff --git a/tests/snippet_tests/test_discover_batch_points.rs b/tests/snippet_tests/test_discover_batch_points.rs deleted file mode 100644 index 975bb5f0..00000000 --- a/tests/snippet_tests/test_discover_batch_points.rs +++ /dev/null @@ -1,55 +0,0 @@ - -#[tokio::test] -async fn test_discover_batch_points() { - async fn discover_batch_points() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/discover_batch_points.rs` file - use qdrant_client::qdrant::{ - vector_example::Example, ContextExamplePairBuilder, DiscoverBatchPointsBuilder, - DiscoverPointsBuilder, - }; - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - let discover_points = DiscoverBatchPointsBuilder::new( - "{collection_name}", - vec![ - DiscoverPointsBuilder::new( - "{collection_name}", - vec![ - ContextExamplePairBuilder::default() - .positive(Example::Id(100.into())) - .negative(Example::Id(718.into())) - .build(), - ContextExamplePairBuilder::default() - .positive(Example::Id(200.into())) - .negative(Example::Id(300.into())) - .build(), - ], - 10, - ) - .build(), - DiscoverPointsBuilder::new( - "{collection_name}", - vec![ - ContextExamplePairBuilder::default() - .positive(Example::Id(342.into())) - .negative(Example::Id(213.into())) - .build(), - ContextExamplePairBuilder::default() - .positive(Example::Id(100.into())) - .negative(Example::Id(200.into())) - .build(), - ], - 10, - ) - .build(), - ], - ); - - client.discover_batch(&discover_points.build()).await?; - Ok(()) - } - let _ = discover_batch_points().await; -} diff --git a/tests/snippet_tests/test_discover_points.rs b/tests/snippet_tests/test_discover_points.rs deleted file mode 100644 index d2c84731..00000000 --- a/tests/snippet_tests/test_discover_points.rs +++ /dev/null @@ -1,39 +0,0 @@ - -#[tokio::test] -async fn test_discover_points() { - async fn discover_points() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/discover_points.rs` file - use qdrant_client::qdrant::{ - target_vector::Target, vector_example::Example, ContextExamplePairBuilder, - DiscoverPointsBuilder, VectorExample, - }; - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client - .discover( - DiscoverPointsBuilder::new( - "{collection_name}", - vec![ - ContextExamplePairBuilder::default() - .positive(Example::Id(100.into())) - .negative(Example::Id(718.into())) - .build(), - ContextExamplePairBuilder::default() - .positive(Example::Id(200.into())) - .negative(Example::Id(300.into())) - .build(), - ], - 10, - ) - .target(Target::Single(VectorExample { - example: Some(Example::Vector(vec![0.2, 0.1, 0.9, 0.7].into())), - })), - ) - .await?; - Ok(()) - } - let _ = discover_points().await; -} diff --git a/tests/snippet_tests/test_facets.rs b/tests/snippet_tests/test_facets.rs deleted file mode 100644 index 951125f8..00000000 --- a/tests/snippet_tests/test_facets.rs +++ /dev/null @@ -1,25 +0,0 @@ - -#[tokio::test] -async fn test_facets() { - async fn facets() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/facets.rs` file - use qdrant_client::qdrant::{Condition, FacetCountsBuilder, Filter}; - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client - .facet( - FacetCountsBuilder::new("world_data", "country") - .limit(10) - .filter(Filter::must(vec![Condition::matches( - "continent", - "Europe".to_string(), - )])), - ) - .await?; - Ok(()) - } - let _ = facets().await; -} diff --git a/tests/snippet_tests/test_get_collection.rs b/tests/snippet_tests/test_get_collection.rs deleted file mode 100644 index b5d9faf7..00000000 --- a/tests/snippet_tests/test_get_collection.rs +++ /dev/null @@ -1,15 +0,0 @@ - -#[tokio::test] -async fn test_get_collection() { - async fn get_collection() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/get_collection.rs` file - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client.collection_info("{collection_name}").await?; - Ok(()) - } - let _ = get_collection().await; -} diff --git a/tests/snippet_tests/test_get_collection_aliases.rs b/tests/snippet_tests/test_get_collection_aliases.rs deleted file mode 100644 index 01a44c7d..00000000 --- a/tests/snippet_tests/test_get_collection_aliases.rs +++ /dev/null @@ -1,15 +0,0 @@ - -#[tokio::test] -async fn test_get_collection_aliases() { - async fn get_collection_aliases() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/get_collection_aliases.rs` file - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client.list_collection_aliases("{collection_name}").await?; - Ok(()) - } - let _ = get_collection_aliases().await; -} diff --git a/tests/snippet_tests/test_get_collections.rs b/tests/snippet_tests/test_get_collections.rs deleted file mode 100644 index c0bec8b3..00000000 --- a/tests/snippet_tests/test_get_collections.rs +++ /dev/null @@ -1,15 +0,0 @@ - -#[tokio::test] -async fn test_get_collections() { - async fn get_collections() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/get_collections.rs` file - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client.list_collections().await?; - Ok(()) - } - let _ = get_collections().await; -} diff --git a/tests/snippet_tests/test_get_collections_aliases.rs b/tests/snippet_tests/test_get_collections_aliases.rs deleted file mode 100644 index 79b48779..00000000 --- a/tests/snippet_tests/test_get_collections_aliases.rs +++ /dev/null @@ -1,15 +0,0 @@ - -#[tokio::test] -async fn test_get_collections_aliases() { - async fn get_collections_aliases() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/get_collections_aliases.rs` file - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client.list_aliases().await?; - Ok(()) - } - let _ = get_collections_aliases().await; -} diff --git a/tests/snippet_tests/test_get_points.rs b/tests/snippet_tests/test_get_points.rs deleted file mode 100644 index 83824c19..00000000 --- a/tests/snippet_tests/test_get_points.rs +++ /dev/null @@ -1,21 +0,0 @@ - -#[tokio::test] -async fn test_get_points() { - async fn get_points() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/get_points.rs` file - use qdrant_client::qdrant::GetPointsBuilder; - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client - .get_points(GetPointsBuilder::new( - "{collection_name}", - vec![0.into(), 30.into(), 100.into()], - )) - .await?; - Ok(()) - } - let _ = get_points().await; -} diff --git a/tests/snippet_tests/test_list_full_snapshots.rs b/tests/snippet_tests/test_list_full_snapshots.rs deleted file mode 100644 index b33a46c0..00000000 --- a/tests/snippet_tests/test_list_full_snapshots.rs +++ /dev/null @@ -1,15 +0,0 @@ - -#[tokio::test] -async fn test_list_full_snapshots() { - async fn list_full_snapshots() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/list_full_snapshots.rs` file - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client.list_full_snapshots().await?; - Ok(()) - } - let _ = list_full_snapshots().await; -} diff --git a/tests/snippet_tests/test_list_snapshots.rs b/tests/snippet_tests/test_list_snapshots.rs deleted file mode 100644 index d6aaf68d..00000000 --- a/tests/snippet_tests/test_list_snapshots.rs +++ /dev/null @@ -1,15 +0,0 @@ - -#[tokio::test] -async fn test_list_snapshots() { - async fn list_snapshots() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/list_snapshots.rs` file - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client.list_snapshots("{collection_name}").await?; - Ok(()) - } - let _ = list_snapshots().await; -} diff --git a/tests/snippet_tests/test_overwrite_payload.rs b/tests/snippet_tests/test_overwrite_payload.rs deleted file mode 100644 index c1d69c92..00000000 --- a/tests/snippet_tests/test_overwrite_payload.rs +++ /dev/null @@ -1,34 +0,0 @@ - -#[tokio::test] -async fn test_overwrite_payload() { - async fn overwrite_payload() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/overwrite_payload.rs` file - use qdrant_client::qdrant::{ - points_selector::PointsSelectorOneOf, PointsIdsList, SetPayloadPointsBuilder, - }; - use qdrant_client::{Qdrant, Payload}; - use serde_json::json; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - let payload: Payload = json!({ - "property1": "string", - "property2": "string", - }) - .try_into() - .unwrap(); - - client - .overwrite_payload( - SetPayloadPointsBuilder::new("{collection_name}", payload) - .points_selector(PointsSelectorOneOf::Points(PointsIdsList { - ids: vec![0.into(), 3.into(), 10.into()], - })) - .wait(true), - ) - .await?; - Ok(()) - } - let _ = overwrite_payload().await; -} diff --git a/tests/snippet_tests/test_query_document.rs b/tests/snippet_tests/test_query_document.rs deleted file mode 100644 index ecd3cea4..00000000 --- a/tests/snippet_tests/test_query_document.rs +++ /dev/null @@ -1,26 +0,0 @@ - -#[tokio::test] -async fn test_query_document() { - async fn query_document() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/query_document.rs` file - use qdrant_client::qdrant::{Document, Query, QueryPointsBuilder}; - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - let query_document = Document::new( - "my query text", - "sentence-transformers/all-minilm-l6-v2" - ); - - let query_request = QueryPointsBuilder::new("{collection_name}") - .query(Query::new_nearest(query_document)); - - // ANN search with server-side inference - client.query(query_request).await?; - - Ok(()) - } - let _ = query_document().await; -} diff --git a/tests/snippet_tests/test_query_image.rs b/tests/snippet_tests/test_query_image.rs deleted file mode 100644 index f98a6e7d..00000000 --- a/tests/snippet_tests/test_query_image.rs +++ /dev/null @@ -1,26 +0,0 @@ - -#[tokio::test] -async fn test_query_image() { - async fn query_image() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/query_image.rs` file - use qdrant_client::qdrant::{Image, Query, QueryPointsBuilder}; - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - let query_image = Image::new_from_url( - "https://picsum.photos/200/300.jpg", - "Qdrant/clip-ViT-B-32-vision" - ); - - let query_request = QueryPointsBuilder::new("{collection_name}") - .query(Query::new_nearest(query_image)); - - // ANN search with server-side inference - client.query(query_request).await?; - - Ok(()) - } - let _ = query_image().await; -} diff --git a/tests/snippet_tests/test_query_points.rs b/tests/snippet_tests/test_query_points.rs deleted file mode 100644 index 80c03e70..00000000 --- a/tests/snippet_tests/test_query_points.rs +++ /dev/null @@ -1,122 +0,0 @@ - -#[tokio::test] -async fn test_query_points() { - async fn query_points() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/query_points.rs` file - use qdrant_client::qdrant::{ - Condition, DecayParamsExpressionBuilder, Expression, FormulaBuilder, Fusion, GeoPoint, - PointId, PrefetchQueryBuilder, Query, QueryPointsBuilder, RecommendInputBuilder, - Sample, - }; - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - // Query nearest by ID - let _nearest = client.query( - QueryPointsBuilder::new("{collection_name}") - .query(PointId::from("43cf51e2-8777-4f52-bc74-c2cbde0c8b04")) - ).await?; - - // Recommend on the average of these vectors - let _recommendations = client.query( - QueryPointsBuilder::new("{collection_name}") - .query(Query::new_recommend( - RecommendInputBuilder::default() - .add_positive(vec![0.1; 8]) - .add_negative(PointId::from(0)) - )) - ).await?; - - // Fusion query - let _hybrid = client.query( - QueryPointsBuilder::new("{collection_name}") - .add_prefetch(PrefetchQueryBuilder::default() - .query(vec![(1, 0.22), (42, 0.8)]) - .using("sparse") - .limit(20u64) - ) - .add_prefetch(PrefetchQueryBuilder::default() - .query(vec![0.01, 0.45, 0.67]) - .using("dense") - .limit(20u64) - ) - .query(Fusion::Rrf) - ).await?; - - // 2-stage query - let _refined = client.query( - QueryPointsBuilder::new("{collection_name}") - .add_prefetch(PrefetchQueryBuilder::default() - .query(vec![0.01, 0.45, 0.67]) - .limit(100u64) - ) - .query(vec![ - vec![0.1, 0.2], - vec![0.2, 0.1], - vec![0.8, 0.9], - ]) - .using("colbert") - .limit(10u64) - ).await?; - - // Random sampling (as of 1.11.0) - let _sampled = client - .query( - QueryPointsBuilder::new("{collection_name}") - .query(Query::new_sample(Sample::Random)) - ) - .await?; - - // Score boost depending on payload conditions (as of 1.14.0) - let _tag_boosted = client.query( - QueryPointsBuilder::new("{collection_name}") - .add_prefetch(PrefetchQueryBuilder::default() - .query(vec![0.01, 0.45, 0.67]) - .limit(100u64) - ) - .query(FormulaBuilder::new(Expression::sum_with([ - Expression::score(), - Expression::mult_with([ - Expression::constant(0.5), - Expression::condition(Condition::matches("tag", ["h1", "h2", "h3", "h4"])), - ]), - Expression::mult_with([ - Expression::constant(0.25), - Expression::condition(Condition::matches("tag", ["p", "li"])), - ]), - ]))) - .limit(10) - ).await?; - - // Score boost geographically closer points (as of 1.14.0) - let _geo_boosted = client.query( - QueryPointsBuilder::new("{collection_name}") - .add_prefetch( - PrefetchQueryBuilder::default() - .query(vec![0.01, 0.45, 0.67]) - .limit(100u64), - ) - .query( - FormulaBuilder::new(Expression::sum_with([ - Expression::score(), - Expression::exp_decay( - DecayParamsExpressionBuilder::new(Expression::geo_distance_with( - // Berlin - GeoPoint { lat: 52.504043, lon: 13.393236 }, - "geo.location", - )) - .scale(5_000.0), - ), - ])) - // Munich - .add_default("geo.location", GeoPoint { lat: 48.137154, lon: 11.576124 }), - ) - .limit(10), - ) - .await?; - Ok(()) - } - let _ = query_points().await; -} diff --git a/tests/snippet_tests/test_query_points_groups.rs b/tests/snippet_tests/test_query_points_groups.rs deleted file mode 100644 index 90647393..00000000 --- a/tests/snippet_tests/test_query_points_groups.rs +++ /dev/null @@ -1,21 +0,0 @@ - -#[tokio::test] -async fn test_query_points_groups() { - async fn query_points_groups() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/query_points_groups.rs` file - use qdrant_client::Qdrant; - use qdrant_client::qdrant::{Query, QueryPointGroupsBuilder}; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client.query_groups( - QueryPointGroupsBuilder::new("{collection_name}", "document_id") - .query(Query::from(vec![0.01, 0.45, 0.67])) - .limit(10u64) - .group_size(5u64) - ).await?; - Ok(()) - } - let _ = query_points_groups().await; -} diff --git a/tests/snippet_tests/test_recommend_batch_points.rs b/tests/snippet_tests/test_recommend_batch_points.rs deleted file mode 100644 index ac7d3d50..00000000 --- a/tests/snippet_tests/test_recommend_batch_points.rs +++ /dev/null @@ -1,39 +0,0 @@ - -#[tokio::test] -async fn test_recommend_batch_points() { - async fn recommend_batch_points() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/recommend_batch_points.rs` file - use qdrant_client::qdrant::{ - Condition, Filter, RecommendBatchPointsBuilder, RecommendPointsBuilder, - }; - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - let filter = Filter::must([Condition::matches("city", "London".to_string())]); - let recommend_queries = vec![ - RecommendPointsBuilder::new("{collection_name}", 3) - .add_positive(100) - .add_positive(231) - .add_negative(718) - .filter(filter.clone()) - .build(), - RecommendPointsBuilder::new("{collection_name}", 3) - .add_positive(200) - .add_positive(67) - .add_negative(300) - .filter(filter.clone()) - .build(), - ]; - - client - .recommend_batch(RecommendBatchPointsBuilder::new( - "{collection_name}", - recommend_queries, - )) - .await?; - Ok(()) - } - let _ = recommend_batch_points().await; -} diff --git a/tests/snippet_tests/test_recommend_point_groups.rs b/tests/snippet_tests/test_recommend_point_groups.rs deleted file mode 100644 index e8183b04..00000000 --- a/tests/snippet_tests/test_recommend_point_groups.rs +++ /dev/null @@ -1,24 +0,0 @@ - -#[tokio::test] -async fn test_recommend_point_groups() { - async fn recommend_point_groups() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/recommend_point_groups.rs` file - use qdrant_client::qdrant::{RecommendPointGroupsBuilder, RecommendStrategy}; - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client - .recommend_groups( - RecommendPointGroupsBuilder::new("{collection_name}", "document_id", 2, 3) - .add_positive(100) - .add_positive(200) - .add_negative(718) - .strategy(RecommendStrategy::AverageVector), - ) - .await?; - Ok(()) - } - let _ = recommend_point_groups().await; -} diff --git a/tests/snippet_tests/test_recommend_points.rs b/tests/snippet_tests/test_recommend_points.rs deleted file mode 100644 index a13fd3cb..00000000 --- a/tests/snippet_tests/test_recommend_points.rs +++ /dev/null @@ -1,30 +0,0 @@ - -#[tokio::test] -async fn test_recommend_points() { - async fn recommend_points() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/recommend_points.rs` file - use qdrant_client::qdrant::{Condition, Filter, RecommendPointsBuilder, RecommendStrategy}; - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client - .recommend( - RecommendPointsBuilder::new("{collection_name}", 3) - .add_positive(100) - .add_positive(200) - .add_positive(vec![100.0, 231.0]) - .add_negative(718) - .add_negative(vec![0.2, 0.3, 0.4, 0.5]) - .strategy(RecommendStrategy::AverageVector) - .filter(Filter::must([Condition::matches( - "city", - "London".to_string(), - )])), - ) - .await?; - Ok(()) - } - let _ = recommend_points().await; -} diff --git a/tests/snippet_tests/test_scroll_points.rs b/tests/snippet_tests/test_scroll_points.rs deleted file mode 100644 index b109692b..00000000 --- a/tests/snippet_tests/test_scroll_points.rs +++ /dev/null @@ -1,27 +0,0 @@ - -#[tokio::test] -async fn test_scroll_points() { - async fn scroll_points() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/scroll_points.rs` file - use qdrant_client::qdrant::{Condition, Filter, ScrollPointsBuilder}; - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client - .scroll( - ScrollPointsBuilder::new("{collection_name}") - .filter(Filter::must([Condition::matches( - "color", - "red".to_string(), - )])) - .limit(1) - .with_payload(true) - .with_vectors(false), - ) - .await?; - Ok(()) - } - let _ = scroll_points().await; -} diff --git a/tests/snippet_tests/test_search_batch_points.rs b/tests/snippet_tests/test_search_batch_points.rs deleted file mode 100644 index 836546a1..00000000 --- a/tests/snippet_tests/test_search_batch_points.rs +++ /dev/null @@ -1,31 +0,0 @@ - -#[tokio::test] -async fn test_search_batch_points() { - async fn search_batch_points() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/search_batch_points.rs` file - use qdrant_client::qdrant::{ - Condition, Filter, SearchBatchPointsBuilder, SearchPointsBuilder, - }; - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - let filter = Filter::must([Condition::matches("city", "London".to_string())]); - - let searches = vec![ - SearchPointsBuilder::new("{collection_name}", vec![0.2, 0.1, 0.9, 0.7], 3) - .filter(filter.clone()) - .build(), - SearchPointsBuilder::new("{collection_name}", vec![0.5, 0.3, 0.2, 0.3], 3) - .filter(filter.clone()) - .build(), - ]; - - client - .search_batch_points(SearchBatchPointsBuilder::new("{collection_name}", searches)) - .await?; - Ok(()) - } - let _ = search_batch_points().await; -} diff --git a/tests/snippet_tests/test_search_matrix_offsets.rs b/tests/snippet_tests/test_search_matrix_offsets.rs deleted file mode 100644 index 276c87c3..00000000 --- a/tests/snippet_tests/test_search_matrix_offsets.rs +++ /dev/null @@ -1,26 +0,0 @@ - -#[tokio::test] -async fn test_search_matrix_offsets() { - async fn search_matrix_offsets() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/search_matrix_offsets.rs` file - use qdrant_client::qdrant::{Condition, SearchMatrixPointsBuilder, Filter}; - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client - .search_matrix_offsets( - SearchMatrixPointsBuilder::new("collection_name") - .filter(Filter::must(vec![Condition::matches( - "color", - "red".to_string(), - )])) - .sample(1000) - .limit(10), - ) - .await?; - Ok(()) - } - let _ = search_matrix_offsets().await; -} diff --git a/tests/snippet_tests/test_search_matrix_pairs.rs b/tests/snippet_tests/test_search_matrix_pairs.rs deleted file mode 100644 index bc4b198d..00000000 --- a/tests/snippet_tests/test_search_matrix_pairs.rs +++ /dev/null @@ -1,26 +0,0 @@ - -#[tokio::test] -async fn test_search_matrix_pairs() { - async fn search_matrix_pairs() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/search_matrix_pairs.rs` file - use qdrant_client::qdrant::{Condition, SearchMatrixPointsBuilder, Filter}; - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client - .search_matrix_pairs( - SearchMatrixPointsBuilder::new("collection_name") - .filter(Filter::must(vec![Condition::matches( - "color", - "red".to_string(), - )])) - .sample(1000) - .limit(10), - ) - .await?; - Ok(()) - } - let _ = search_matrix_pairs().await; -} diff --git a/tests/snippet_tests/test_search_point_groups.rs b/tests/snippet_tests/test_search_point_groups.rs deleted file mode 100644 index 85cf8a27..00000000 --- a/tests/snippet_tests/test_search_point_groups.rs +++ /dev/null @@ -1,24 +0,0 @@ - -#[tokio::test] -async fn test_search_point_groups() { - async fn search_point_groups() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/search_point_groups.rs` file - use qdrant_client::qdrant::SearchPointGroupsBuilder; - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client - .search_groups(SearchPointGroupsBuilder::new( - "{collection_name}", - vec![1.1], - 4, - "document_id", - 2, - )) - .await?; - Ok(()) - } - let _ = search_point_groups().await; -} diff --git a/tests/snippet_tests/test_search_points.rs b/tests/snippet_tests/test_search_points.rs deleted file mode 100644 index 6e6db0a9..00000000 --- a/tests/snippet_tests/test_search_points.rs +++ /dev/null @@ -1,25 +0,0 @@ - -#[tokio::test] -async fn test_search_points() { - async fn search_points() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/search_points.rs` file - use qdrant_client::qdrant::{Condition, Filter, SearchParamsBuilder, SearchPointsBuilder}; - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client - .search_points( - SearchPointsBuilder::new("{collection_name}", vec![0.2, 0.1, 0.9, 0.7], 3) - .filter(Filter::must([Condition::matches( - "city", - "London".to_string(), - )])) - .params(SearchParamsBuilder::default().hnsw_ef(128).exact(false)), - ) - .await?; - Ok(()) - } - let _ = search_points().await; -} diff --git a/tests/snippet_tests/test_set_payload.rs b/tests/snippet_tests/test_set_payload.rs deleted file mode 100644 index 293e0bb0..00000000 --- a/tests/snippet_tests/test_set_payload.rs +++ /dev/null @@ -1,32 +0,0 @@ - -#[tokio::test] -async fn test_set_payload() { - async fn set_payload() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/set_payload.rs` file - use qdrant_client::qdrant::{PointsIdsList, SetPayloadPointsBuilder}; - use qdrant_client::{Qdrant, Payload}; - use serde_json::json; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - let payload: Payload = json!({ - "property1": "string", - "property2": "string", - }) - .try_into() - .unwrap(); - - client - .set_payload( - SetPayloadPointsBuilder::new("{collection_name}", payload) - .points_selector(PointsIdsList { - ids: vec![0.into(), 3.into(), 10.into()], - }) - .wait(true), - ) - .await?; - Ok(()) - } - let _ = set_payload().await; -} diff --git a/tests/snippet_tests/test_update_aliases.rs b/tests/snippet_tests/test_update_aliases.rs deleted file mode 100644 index cedcf782..00000000 --- a/tests/snippet_tests/test_update_aliases.rs +++ /dev/null @@ -1,27 +0,0 @@ - -#[tokio::test] -async fn test_update_aliases() { - async fn update_aliases() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/update_aliases.rs` file - use qdrant_client::qdrant::{CreateAliasBuilder, DeleteAlias}; - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client - .create_alias(CreateAliasBuilder::new( - "example_collection", - "production_collection", - )) - .await?; - - client - .delete_alias(DeleteAlias { - alias_name: "production_collection".to_string(), - }) - .await?; - Ok(()) - } - let _ = update_aliases().await; -} diff --git a/tests/snippet_tests/test_update_collection.rs b/tests/snippet_tests/test_update_collection.rs deleted file mode 100644 index 5864034e..00000000 --- a/tests/snippet_tests/test_update_collection.rs +++ /dev/null @@ -1,22 +0,0 @@ - -#[tokio::test] -async fn test_update_collection() { - async fn update_collection() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/update_collection.rs` file - use qdrant_client::qdrant::{OptimizersConfigDiffBuilder, UpdateCollectionBuilder}; - use qdrant_client::Qdrant; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client - .update_collection( - UpdateCollectionBuilder::new("{collection_name}").optimizers_config( - OptimizersConfigDiffBuilder::default().indexing_threshold(10_000), - ), - ) - .await?; - Ok(()) - } - let _ = update_collection().await; -} diff --git a/tests/snippet_tests/test_update_vectors.rs b/tests/snippet_tests/test_update_vectors.rs deleted file mode 100644 index 822fd3c6..00000000 --- a/tests/snippet_tests/test_update_vectors.rs +++ /dev/null @@ -1,43 +0,0 @@ - -#[tokio::test] -async fn test_update_vectors() { - async fn update_vectors() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/update_vectors.rs` file - use qdrant_client::qdrant::{PointVectors, UpdatePointVectorsBuilder}; - use qdrant_client::Qdrant; - use std::collections::HashMap; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client - .update_vectors( - UpdatePointVectorsBuilder::new( - "{collection_name}", - vec![ - PointVectors { - id: Some(1.into()), - vectors: Some( - HashMap::from([("image".to_string(), vec![0.1, 0.2, 0.3, 0.4])]) - .into(), - ), - }, - PointVectors { - id: Some(2.into()), - vectors: Some( - HashMap::from([( - "text".to_string(), - vec![0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2], - )]) - .into(), - ), - }, - ], - ) - .wait(true), - ) - .await?; - Ok(()) - } - let _ = update_vectors().await; -} diff --git a/tests/snippet_tests/test_upsert_document.rs b/tests/snippet_tests/test_upsert_document.rs deleted file mode 100644 index 0c00ae44..00000000 --- a/tests/snippet_tests/test_upsert_document.rs +++ /dev/null @@ -1,36 +0,0 @@ - -#[tokio::test] -async fn test_upsert_document() { - async fn upsert_document() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/upsert_document.rs` file - use qdrant_client::qdrant::{PointStruct, UpsertPointsBuilder, Document}; - use qdrant_client::{Qdrant, Payload}; - use serde_json::json; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - let document = Document::new("my document", "sentence-transformers/all-minilm-l6-v2"); - - client - .upsert_points( - UpsertPointsBuilder::new( - "{collection_name}", - vec![ - PointStruct::new( - 1, - document, - Payload::try_from(json!( - {"color": "red"} - )) - .unwrap(), - ) - ], - ) - .wait(true), - ) - .await?; - Ok(()) - } - let _ = upsert_document().await; -} diff --git a/tests/snippet_tests/test_upsert_image.rs b/tests/snippet_tests/test_upsert_image.rs deleted file mode 100644 index 0d7211a6..00000000 --- a/tests/snippet_tests/test_upsert_image.rs +++ /dev/null @@ -1,36 +0,0 @@ - -#[tokio::test] -async fn test_upsert_image() { - async fn upsert_image() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/upsert_image.rs` file - use qdrant_client::qdrant::{PointStruct, UpsertPointsBuilder, Image}; - use qdrant_client::{Qdrant, Payload}; - use serde_json::json; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - let image = Image::new_from_url("https://picsum.photos/200/300.jpg", "Qdrant/clip-ViT-B-32-vision"); - - client - .upsert_points( - UpsertPointsBuilder::new( - "{collection_name}", - vec![ - PointStruct::new( - 1, - image, - Payload::try_from(json!( - {"color": "red"} - )) - .unwrap(), - ) - ], - ) - .wait(true), - ) - .await?; - Ok(()) - } - let _ = upsert_image().await; -} diff --git a/tests/snippet_tests/test_upsert_points.rs b/tests/snippet_tests/test_upsert_points.rs deleted file mode 100644 index 28741e13..00000000 --- a/tests/snippet_tests/test_upsert_points.rs +++ /dev/null @@ -1,50 +0,0 @@ - -#[tokio::test] -async fn test_upsert_points() { - async fn upsert_points() -> Result<(), Box> { - // WARNING: This is a generated test snippet. - // Please, modify the snippet in the `../snippets/upsert_points.rs` file - use qdrant_client::qdrant::{PointStruct, UpsertPointsBuilder}; - use qdrant_client::{Qdrant, Payload}; - use serde_json::json; - - let client = Qdrant::from_url("http://localhost:6334").build()?; - - client - .upsert_points( - UpsertPointsBuilder::new( - "{collection_name}", - vec![ - PointStruct::new( - 1, - vec![0.9, 0.1, 0.1], - Payload::try_from(json!( - {"color": "red"} - )) - .unwrap(), - ), - PointStruct::new( - 2, - vec![0.1, 0.9, 0.1], - Payload::try_from(json!( - {"color": "green"} - )) - .unwrap(), - ), - PointStruct::new( - 3, - vec![0.1, 0.1, 0.9], - Payload::try_from(json!( - {"color": "blue"} - )) - .unwrap(), - ), - ], - ) - .wait(true), - ) - .await?; - Ok(()) - } - let _ = upsert_points().await; -} diff --git a/tests/test_snippets.rs b/tests/test_snippets.rs index 872a5d3e..c9e2a7b7 100644 --- a/tests/test_snippets.rs +++ b/tests/test_snippets.rs @@ -1,7 +1,9 @@ // Skip formatting for this file #[rustfmt::skip] -mod snippet_tests; +mod snippet_tests { + include!(concat!(env!("OUT_DIR"), "/tests/snippet_tests/mod.rs")); +} // WARNING: Snippet tests are not checking if the request is executing correctly. // The only thing it is checking is if the code compiles and runs without panicking.