From ec7de579df14425b7e3c19373dc2fd38e2934005 Mon Sep 17 00:00:00 2001 From: Clementine Urquizar Date: Wed, 29 Jul 2020 14:46:32 +0200 Subject: [PATCH] Use master-key in tests suite --- .github/workflows/rust.yml | 2 +- README.md | 2 +- src/client.rs | 16 ++++++------ src/indexes.rs | 22 ++++++++-------- src/lib.rs | 2 +- src/progress.rs | 2 +- src/settings.rs | 52 +++++++++++++++++++------------------- 7 files changed, 49 insertions(+), 49 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 4a691fe5..e64bbcf0 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -18,6 +18,6 @@ jobs: - name: Build run: cargo build --verbose - name: Docker setup - run: docker run -d -p 7700:7700 getmeili/meilisearch:latest ./meilisearch --no-analytics=true + run: docker run -d -p 7700:7700 getmeili/meilisearch:latest ./meilisearch --no-analytics=true --master-key=masterKey - name: Run tests run: cargo test --verbose -- --test-threads=1 diff --git a/README.md b/README.md index b8595cfc..0246ae28 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ impl Document for Book { #[tokio::main] async fn main() { // Create a client (without sending any request so that can't fail) - let client = Client::new("http://localhost:7700", ""); + let client = Client::new("http://localhost:7700", "masterKey"); // Get the index called "books" let mut books = client.get_or_create("books").await.unwrap(); diff --git a/src/client.rs b/src/client.rs index 726cc23e..262fe334 100644 --- a/src/client.rs +++ b/src/client.rs @@ -22,7 +22,7 @@ impl<'a> Client<'a> { /// # use meilisearch_sdk::{client::*, indexes::*}; /// # /// // create the client - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// ``` pub const fn new(host: &'a str, apikey: &'a str) -> Client<'a> { Client { host, apikey } @@ -37,7 +37,7 @@ impl<'a> Client<'a> { /// # #[tokio::main] /// # async fn main() { /// // create the client - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// /// let indexes: Vec = client.list_all_indexes().await.unwrap(); /// println!("{:?}", indexes); @@ -69,7 +69,7 @@ impl<'a> Client<'a> { /// # #[tokio::main] /// # async fn main() { /// // create the client - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// # client.create_index("movies", None).await; /// /// // get the index named "movies" @@ -104,7 +104,7 @@ impl<'a> Client<'a> { /// # #[tokio::main] /// # async fn main() { /// // create the client - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// /// # if let Ok(mut movies) = client.get_index("movies").await { /// # movies.delete().await.unwrap(); @@ -164,7 +164,7 @@ impl<'a> Client<'a> { /// # /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let stats = client.get_stats().await.unwrap(); /// # } /// ``` @@ -186,7 +186,7 @@ impl<'a> Client<'a> { /// # /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// /// match client.get_health().await { /// Ok(()) => println!("server is operationnal"), @@ -217,7 +217,7 @@ impl<'a> Client<'a> { /// # /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// /// client.set_health(false).await.unwrap(); /// # client.set_health(true).await.unwrap(); @@ -250,7 +250,7 @@ impl<'a> Client<'a> { /// # /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let version = client.get_version().await.unwrap(); /// # } /// ``` diff --git a/src/indexes.rs b/src/indexes.rs index 413181fd..afac42b8 100644 --- a/src/indexes.rs +++ b/src/indexes.rs @@ -31,7 +31,7 @@ impl JsonIndex { /// # use meilisearch_sdk::{client::*, indexes::*}; /// # #[tokio::main] /// # async fn main() { -/// let client = Client::new("http://localhost:7700", ""); +/// let client = Client::new("http://localhost:7700", "masterKey"); /// /// // get the index called movies or create it if it does not exist /// let movies = client.get_or_create("movies").await.unwrap(); @@ -67,7 +67,7 @@ impl<'a> Index<'a> { /// # use meilisearch_sdk::{client::*, indexes::*}; /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// # client.create_index("movies", None).await; /// /// // get the index named "movies" and delete it @@ -107,7 +107,7 @@ impl<'a> Index<'a> { /// /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let mut movies = client.get_or_create("movies").await.unwrap(); /// /// // add some documents @@ -163,7 +163,7 @@ impl<'a> Index<'a> { /// /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// # client.create_index("movies", None).await; /// let movies = client.get_index("movies").await.unwrap(); /// # let mut movies = client.get_index("movies").await.unwrap(); @@ -222,7 +222,7 @@ impl<'a> Index<'a> { /// /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// # client.create_index("movies", None).await; /// let movie_index = client.get_index("movies").await.unwrap(); /// # let mut movie_index = client.get_index("movies").await.unwrap(); @@ -297,7 +297,7 @@ impl<'a> Index<'a> { /// /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let mut movie_index = client.get_or_create("movies").await.unwrap(); /// /// movie_index.add_or_replace(&[ @@ -385,7 +385,7 @@ impl<'a> Index<'a> { /// /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let mut movie_index = client.get_or_create("movies").await.unwrap(); /// /// movie_index.add_or_update(&[ @@ -454,7 +454,7 @@ impl<'a> Index<'a> { /// # #[tokio::main] /// # async fn main() { /// # - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let mut movie_index = client.get_or_create("movies").await.unwrap(); /// /// // add some documents @@ -499,7 +499,7 @@ impl<'a> Index<'a> { /// # #[tokio::main] /// # async fn main() { /// # - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let mut movies = client.get_or_create("movies").await.unwrap(); /// /// # movies.add_or_replace(&[Movie{name:String::from("Interstellar"), description:String::from("Interstellar chronicles the adventures of a group of explorers who make use of a newly discovered wormhole to surpass the limitations on human space travel and conquer the vast distances involved in an interstellar voyage.")}], Some("name")).await.unwrap(); @@ -547,7 +547,7 @@ impl<'a> Index<'a> { /// # #[tokio::main] /// # async fn main() { /// # - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let mut movies = client.get_or_create("movies").await.unwrap(); /// /// // add some documents @@ -588,7 +588,7 @@ impl<'a> Index<'a> { /// # /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let movies = client.get_or_create("movies").await.unwrap(); /// /// let stats = movies.get_stats().await.unwrap(); diff --git a/src/lib.rs b/src/lib.rs index 42b9eb24..0f1b67a7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -46,7 +46,7 @@ //! #[tokio::main] //! async fn main() { //! // Create a client (without sending any request so that can't fail) -//! let client = Client::new("http://localhost:7700", ""); +//! let client = Client::new("http://localhost:7700", "masterKey"); //! //! // Get the index called "books" //! let mut books = client.get_or_create("books").await.unwrap(); diff --git a/src/progress.rs b/src/progress.rs index 8bde05a9..8b308bc8 100644 --- a/src/progress.rs +++ b/src/progress.rs @@ -34,7 +34,7 @@ impl<'a> Progress<'a> { /// # use meilisearch_sdk::{client::*, indexes::*, document::*}; /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let mut movies_index = client.get_or_create("movies").await.unwrap(); /// let progress = movies_index.delete_all_documents().await.unwrap(); /// let status = progress.get_status().await.unwrap(); diff --git a/src/settings.rs b/src/settings.rs index 8d371a7d..635833b7 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -130,7 +130,7 @@ impl<'a> Index<'a> { /// # use meilisearch_sdk::{client::*, indexes::*, document::*}; /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let movie_index = client.get_or_create("movies").await.unwrap(); /// let settings = movie_index.get_settings().await.unwrap(); /// # } @@ -150,7 +150,7 @@ impl<'a> Index<'a> { /// # use meilisearch_sdk::{client::*, indexes::*, document::*}; /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let movie_index = client.get_or_create("movies").await.unwrap(); /// let synonyms = movie_index.get_synonyms().await.unwrap(); /// # } @@ -170,7 +170,7 @@ impl<'a> Index<'a> { /// # use meilisearch_sdk::{client::*, indexes::*, document::*}; /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let movie_index = client.get_or_create("movies").await.unwrap(); /// let stop_words = movie_index.get_stop_words().await.unwrap(); /// # } @@ -190,7 +190,7 @@ impl<'a> Index<'a> { /// # use meilisearch_sdk::{client::*, indexes::*, document::*}; /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let movie_index = client.get_or_create("movies").await.unwrap(); /// let ranking_rules = movie_index.get_ranking_rules().await.unwrap(); /// # } @@ -210,7 +210,7 @@ impl<'a> Index<'a> { /// # use meilisearch_sdk::{client::*, indexes::*, document::*}; /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let movie_index = client.get_or_create("movies").await.unwrap(); /// let attributes_for_faceting = movie_index.get_attributes_for_faceting().await.unwrap(); /// # } @@ -230,7 +230,7 @@ impl<'a> Index<'a> { /// # use meilisearch_sdk::{client::*, indexes::*, document::*}; /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let movie_index = client.get_or_create("movies").await.unwrap(); /// let distinct_attribute = movie_index.get_distinct_attribute().await.unwrap(); /// # } @@ -250,7 +250,7 @@ impl<'a> Index<'a> { /// # use meilisearch_sdk::{client::*, indexes::*, document::*}; /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let movie_index = client.get_or_create("movies").await.unwrap(); /// let searchable_attributes = movie_index.get_searchable_attributes().await.unwrap(); /// # } @@ -270,7 +270,7 @@ impl<'a> Index<'a> { /// # use meilisearch_sdk::{client::*, indexes::*, document::*}; /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let movie_index = client.get_or_create("movies").await.unwrap(); /// let displayed_attributes = movie_index.get_displayed_attributes().await.unwrap(); /// # } @@ -290,7 +290,7 @@ impl<'a> Index<'a> { /// # use meilisearch_sdk::{client::*, indexes::*, document::*}; /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let movie_index = client.get_or_create("movies").await.unwrap(); /// let accept_new_field = movie_index.get_accept_new_fields().await.unwrap(); /// # } @@ -313,7 +313,7 @@ impl<'a> Index<'a> { /// # use meilisearch_sdk::{client::*, indexes::*, document::*, settings::Settings}; /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let mut movie_index = client.get_or_create("movies").await.unwrap(); /// /// let stop_words = vec![String::from("a"), String::from("the"), String::from("of")]; @@ -342,7 +342,7 @@ impl<'a> Index<'a> { /// # use meilisearch_sdk::{client::*, indexes::*, document::*, settings::Settings}; /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let mut movie_index = client.get_or_create("movies").await.unwrap(); /// /// let mut synonyms = std::collections::HashMap::new(); @@ -371,7 +371,7 @@ impl<'a> Index<'a> { /// # use meilisearch_sdk::{client::*, indexes::*, document::*, settings::Settings}; /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let mut movie_index = client.get_or_create("movies").await.unwrap(); /// /// let stop_words = &["the", "of", "to"]; @@ -396,7 +396,7 @@ impl<'a> Index<'a> { /// # use meilisearch_sdk::{client::*, indexes::*, document::*, settings::Settings}; /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let mut movie_index = client.get_or_create("movies").await.unwrap(); /// /// let ranking_rules = &[ @@ -430,7 +430,7 @@ impl<'a> Index<'a> { /// # use meilisearch_sdk::{client::*, indexes::*, document::*, settings::Settings}; /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let mut movie_index = client.get_or_create("movies").await.unwrap(); /// /// let attributes_for_faceting = &["genre", "director"]; @@ -455,7 +455,7 @@ impl<'a> Index<'a> { /// # use meilisearch_sdk::{client::*, indexes::*, document::*, settings::Settings}; /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let mut movie_index = client.get_or_create("movies").await.unwrap(); /// /// let progress = movie_index.set_distinct_attribute("movie_id").await.unwrap(); @@ -479,7 +479,7 @@ impl<'a> Index<'a> { /// # use meilisearch_sdk::{client::*, indexes::*, document::*, settings::Settings}; /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let mut movie_index = client.get_or_create("movies").await.unwrap(); /// /// let progress = movie_index.set_searchable_attributes(&["title", "description", "uid"]).await.unwrap(); @@ -503,7 +503,7 @@ impl<'a> Index<'a> { /// # use meilisearch_sdk::{client::*, indexes::*, document::*, settings::Settings}; /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let mut movie_index = client.get_or_create("movies").await.unwrap(); /// /// let progress = movie_index.set_displayed_attributes(&["title", "description", "release_date", "rank", "poster"]).await.unwrap(); @@ -527,7 +527,7 @@ impl<'a> Index<'a> { /// # use meilisearch_sdk::{client::*, indexes::*, document::*, settings::Settings}; /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let mut movie_index = client.get_or_create("movies").await.unwrap(); /// /// let progress = movie_index.set_accept_new_fields(false).await.unwrap(); @@ -552,7 +552,7 @@ impl<'a> Index<'a> { /// # use meilisearch_sdk::{client::*, indexes::*, document::*, settings::Settings}; /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let mut movie_index = client.get_or_create("movies").await.unwrap(); /// /// let progress = movie_index.reset_settings().await.unwrap(); @@ -576,7 +576,7 @@ impl<'a> Index<'a> { /// # use meilisearch_sdk::{client::*, indexes::*, document::*, settings::Settings}; /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let mut movie_index = client.get_or_create("movies").await.unwrap(); /// /// let progress = movie_index.reset_synonyms().await.unwrap(); @@ -600,7 +600,7 @@ impl<'a> Index<'a> { /// # use meilisearch_sdk::{client::*, indexes::*, document::*, settings::Settings}; /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let mut movie_index = client.get_or_create("movies").await.unwrap(); /// /// let progress = movie_index.reset_stop_words().await.unwrap(); @@ -625,7 +625,7 @@ impl<'a> Index<'a> { /// # use meilisearch_sdk::{client::*, indexes::*, document::*, settings::Settings}; /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let mut movie_index = client.get_or_create("movies").await.unwrap(); /// /// let progress = movie_index.reset_ranking_rules().await.unwrap(); @@ -649,7 +649,7 @@ impl<'a> Index<'a> { /// # use meilisearch_sdk::{client::*, indexes::*, document::*, settings::Settings}; /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let mut movie_index = client.get_or_create("movies").await.unwrap(); /// /// let progress = movie_index.reset_attributes_for_faceting().await.unwrap(); @@ -673,7 +673,7 @@ impl<'a> Index<'a> { /// # use meilisearch_sdk::{client::*, indexes::*, document::*, settings::Settings}; /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let mut movie_index = client.get_or_create("movies").await.unwrap(); /// /// let progress = movie_index.reset_distinct_attribute().await.unwrap(); @@ -697,7 +697,7 @@ impl<'a> Index<'a> { /// # use meilisearch_sdk::{client::*, indexes::*, document::*, settings::Settings}; /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let mut movie_index = client.get_or_create("movies").await.unwrap(); /// /// let progress = movie_index.reset_searchable_attributes().await.unwrap(); @@ -721,7 +721,7 @@ impl<'a> Index<'a> { /// # use meilisearch_sdk::{client::*, indexes::*, document::*, settings::Settings}; /// # #[tokio::main] /// # async fn main() { - /// let client = Client::new("http://localhost:7700", ""); + /// let client = Client::new("http://localhost:7700", "masterKey"); /// let mut movie_index = client.get_or_create("movies").await.unwrap(); /// /// let progress = movie_index.reset_displayed_attributes().await.unwrap();