From 1425d62a31b3601775089cb5951a72d6dc079ec1 Mon Sep 17 00:00:00 2001 From: ad hoc Date: Thu, 9 Jun 2022 18:08:26 +0200 Subject: [PATCH 1/2] test dump v5 --- .../tests/assets/v5_v0.28.0_test_dump.dump | Bin 0 -> 5429 bytes meilisearch-http/tests/common/server.rs | 11 ++- meilisearch-http/tests/dumps/data.rs | 5 ++ meilisearch-http/tests/dumps/mod.rs | 71 +++++++++++++++++- 4 files changed, 82 insertions(+), 5 deletions(-) create mode 100644 meilisearch-http/tests/assets/v5_v0.28.0_test_dump.dump diff --git a/meilisearch-http/tests/assets/v5_v0.28.0_test_dump.dump b/meilisearch-http/tests/assets/v5_v0.28.0_test_dump.dump new file mode 100644 index 0000000000000000000000000000000000000000..bc30ea7b91a7f2d0015e3b83f90b03daf0e9843a GIT binary patch literal 5429 zcmbuC!PhB@g(w8s1qkFqGQ?gPOkg57*1IpWN>14xFYgg~f4X_Kpc!Y-8 zA|x|qR3Gsjp_bbjnVc=Zz;dQiraVatfr?FRLXECG00m}(xs6k>uk~s9_g{^$Y0ANd zxbpp-3R7OPN7ccmn}SEM<$Ah#CMHQe|J1Nm1U&W9}34?Vf`%=mkJ9U{apE%MkSi~JmD7CkPyMnw5UFbtJK)>R6S+!23FNhOn z8vg+?uWi}Q4;j*+ik*5R4~-gE!Xy)JVUR~38@d7<@gd>!vLpq9uezihv$vPN! zhLZ{*EW+hMLhSp+0}e;_b42?mANW=-_(?8zk)hwh4QjXZV>B%*XkI5GYOMqEE#UtD zEQ=!NWkMt_SNX)8;1++EKRvf8$0*zWCCLx)dRDb0m4LIz8(bB5HxJ5P5ol`C30PLN>ld@ALA*_b)mWc-pt|RkUEgE*1V`)ztb!&7!vIJ4sC;}AU9btm1 z6?8t7ahqUf?O>|{l;x%z+SWIwVrcQQ=}!_yIC~K;8wObk7SGkd@~H?zQZ;d=DS|{0 zx+zUw)rt3@Ro>c0Lc~;Q=?n($M2h-aCTo$2sQ92HnlHrGAHx&yg=0e2a?OK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C5(^sZ`0|ZBd?#aJZ?es(mFljrq*Ms>VFV9z6nSSCW9ilAt3x8 DhaK7& literal 0 HcmV?d00001 diff --git a/meilisearch-http/tests/common/server.rs b/meilisearch-http/tests/common/server.rs index 2dd235e8f..88cacd0ee 100644 --- a/meilisearch-http/tests/common/server.rs +++ b/meilisearch-http/tests/common/server.rs @@ -52,16 +52,13 @@ impl Server { } } - pub async fn new_auth() -> Self { - let dir = TempDir::new().unwrap(); - + pub async fn new_auth_with_options(mut options: Opt, dir: TempDir) -> Self { if cfg!(windows) { std::env::set_var("TMP", TEST_TEMP_DIR.path()); } else { std::env::set_var("TMPDIR", TEST_TEMP_DIR.path()); } - let mut options = default_settings(dir.path()); options.master_key = Some("MASTER_KEY".to_string()); let meilisearch = setup_meilisearch(&options).unwrap(); @@ -79,6 +76,12 @@ impl Server { } } + pub async fn new_auth() -> Self { + let dir = TempDir::new().unwrap(); + let options = default_settings(dir.path()); + Self::new_auth_with_options(options, dir).await + } + pub async fn new_with_options(options: Opt) -> Result { let meilisearch = setup_meilisearch(&options)?; let auth = AuthController::new(&options.db_path, &options.master_key)?; diff --git a/meilisearch-http/tests/dumps/data.rs b/meilisearch-http/tests/dumps/data.rs index a5d7f3426..5df09bfd1 100644 --- a/meilisearch-http/tests/dumps/data.rs +++ b/meilisearch-http/tests/dumps/data.rs @@ -18,6 +18,8 @@ pub enum GetDump { MoviesRawV4, MoviesWithSettingsV4, RubyGemsWithSettingsV4, + + TestV5, } impl GetDump { @@ -63,6 +65,9 @@ impl GetDump { GetDump::RubyGemsWithSettingsV4 => { exist_relative_path!("tests/assets/v4_v0.25.2_rubygems_with_settings.dump").into() } + GetDump::TestV5 => { + exist_relative_path!("tests/assets/v5_v0.28.0_test_dump.dump").into() + } } } } diff --git a/meilisearch-http/tests/dumps/mod.rs b/meilisearch-http/tests/dumps/mod.rs index c26b0e06e..b171330e0 100644 --- a/meilisearch-http/tests/dumps/mod.rs +++ b/meilisearch-http/tests/dumps/mod.rs @@ -1,6 +1,6 @@ mod data; -use crate::common::{default_settings, Server}; +use crate::common::{default_settings, GetAllDocumentsOptions, Server}; use meilisearch_http::Opt; use serde_json::json; @@ -605,3 +605,72 @@ async fn import_dump_v4_rubygems_with_settings() { json!({ "name": "vortex-of-agony", "summary": "You dont need to use nodejs or go, just install this plugin. It will crash your application at random", "description": "You dont need to use nodejs or go, just install this plugin. It will crash your application at random", "id": "159227", "version": "0.1.0", "total_downloads": "1007"}) ); } + +#[actix_rt::test] +async fn import_dump_v5() { + let temp = tempfile::tempdir().unwrap(); + + let options = Opt { + import_dump: Some(GetDump::TestV5.path()), + ..default_settings(temp.path()) + }; + let mut server = Server::new_auth_with_options(options, temp).await; + server.use_api_key("MASTER_KEY"); + + let (indexes, code) = server.list_indexes(None, None).await; + assert_eq!(code, 200, "{indexes}"); + + assert_eq!(indexes["results"].as_array().unwrap().len(), 2); + assert_eq!(indexes["results"][0]["uid"], json!("test")); + assert_eq!(indexes["results"][1]["uid"], json!("test2")); + assert_eq!(indexes["results"][0]["primaryKey"], json!("id")); + + let expected_stats = json!({ + "numberOfDocuments": 10, + "isIndexing": false, + "fieldDistribution": { + "cast": 10, + "director": 10, + "genres": 10, + "id": 10, + "overview": 10, + "popularity": 10, + "poster_path": 10, + "producer": 10, + "production_companies": 10, + "release_date": 10, + "tagline": 10, + "title": 10, + "vote_average": 10, + "vote_count": 10 + } + }); + + let index1 = server.index("test"); + let index2 = server.index("test2"); + + let (stats, code) = index1.stats().await; + assert_eq!(code, 200); + assert_eq!(stats, expected_stats); + + let (docs, code) = index2 + .get_all_documents(GetAllDocumentsOptions::default()) + .await; + assert_eq!(code, 200); + assert_eq!(docs["results"].as_array().unwrap().len(), 10); + let (docs, code) = index1 + .get_all_documents(GetAllDocumentsOptions::default()) + .await; + assert_eq!(code, 200); + assert_eq!(docs["results"].as_array().unwrap().len(), 10); + + let (stats, code) = index2.stats().await; + assert_eq!(code, 200); + assert_eq!(stats, expected_stats); + + let (keys, code) = server.list_api_keys().await; + assert_eq!(code, 200); + let key = &keys["results"][0]; + + assert_eq!(key["name"], "my key"); +} From 97daea5a66dd7429a3a42f35f0234924e41830ec Mon Sep 17 00:00:00 2001 From: ad hoc Date: Mon, 13 Jun 2022 09:16:36 +0100 Subject: [PATCH 2/2] ignore dump test on windows --- meilisearch-http/tests/dumps/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/meilisearch-http/tests/dumps/mod.rs b/meilisearch-http/tests/dumps/mod.rs index b171330e0..3241a7b45 100644 --- a/meilisearch-http/tests/dumps/mod.rs +++ b/meilisearch-http/tests/dumps/mod.rs @@ -607,6 +607,7 @@ async fn import_dump_v4_rubygems_with_settings() { } #[actix_rt::test] +#[cfg_attr(target_os = "windows", ignore)] async fn import_dump_v5() { let temp = tempfile::tempdir().unwrap();