From ca27bcaac72bfcc08252e9e0fe2207ac442a2ba4 Mon Sep 17 00:00:00 2001 From: Mubelotix Date: Thu, 31 Jul 2025 11:34:47 +0200 Subject: [PATCH] Update tests --- crates/dump/src/reader/mod.rs | 16 ++--- .../dump/tests/assets/v6-with-webhooks.dump | Bin 1913 -> 1389 bytes crates/meilisearch/tests/tasks/webhook.rs | 58 +++++++++++------- 3 files changed, 43 insertions(+), 31 deletions(-) diff --git a/crates/dump/src/reader/mod.rs b/crates/dump/src/reader/mod.rs index 85e5df432..844aadc99 100644 --- a/crates/dump/src/reader/mod.rs +++ b/crates/dump/src/reader/mod.rs @@ -449,7 +449,7 @@ pub(crate) mod test { let dump = DumpReader::open(dump).unwrap(); // top level infos - insta::assert_snapshot!(dump.date().unwrap(), @"2025-07-31 7:28:28.091553 +00:00:00"); + insta::assert_snapshot!(dump.date().unwrap(), @"2025-07-31 9:21:30.479544 +00:00:00"); insta::assert_debug_snapshot!(dump.instance_uid().unwrap(), @r" Some( cb887dcc-34b3-48d1-addd-9815ae721a81, @@ -462,23 +462,23 @@ pub(crate) mod test { insta::assert_json_snapshot!(webhooks, @r#" { "webhooks": { - "_cli": { + "00000000-0000-0000-0000-000000000000": { "url": "https://defined-in-dump.com/", "headers": { "Authorization": "Bearer defined in dump" } }, - "exampleName": { + "627ea538-733d-4545-8d2d-03526eb381ce": { + "url": "https://example.com/authorization-less", + "headers": {} + }, + "771b0a28-ef28-4082-b984-536f82958c65": { "url": "https://example.com/hook", "headers": { "authorization": "TOKEN" } }, - "otherName": { - "url": "https://example.com/authorization-less", - "headers": {} - }, - "third": { + "f3583083-f8a7-4cbf-a5e7-fb3f1e28a7e9": { "url": "https://third.com", "headers": {} } diff --git a/crates/dump/tests/assets/v6-with-webhooks.dump b/crates/dump/tests/assets/v6-with-webhooks.dump index 83989f25c4cc882dafeea5c60d917d594867f019..c8f9649d88429ab8c16f3375f94a6c4474d3e79f 100644 GIT binary patch literal 1389 zcmV-z1(Nz7iwFP!00000|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p`Ff=7 zNz9U|YI3cF!K|%K? zRw2dF@$e4$Uk0%zm;XHjO!WCgY2P&l>_4IWf&4LvsI&iP0N8)kWOcsm(-uEA5LwqI zn%qEG7Xq%cx?0#UHvA~HDkZprQY?%cxKuL%TQKj3j`G=eUwhxE8@O&WIlfF&G8Ksm zlt@ItaGC~bmhnK&NF)gtl#2w2Mb_`?e(}30{a^c3jIxcNnR5tJG^2_Knc^g1oT@;i8RWxeOv)Ic zX-a3?-2CiljO3IY$VW@LmyPgN!DJFrH^9(^WtS(iy6O`p*Ym1?bP23Rr=n4N83|Ho zOxEl`c0wXS2H%=o!Q+fgW>ZQcf`cg)3K*M3K_UnWIO8lqsQ_i(Wo!tc3}~{p)BHRV zpCQvr=wXcRN#Dk4n=2Hhe1alBH(hr5!{Ri>(*(n)&M~PN%*Y^%t+u|YWZ*! z+ib?z>G08q$!zh!=(Kp3`d^BP+y9*bR{j^ABYio`i&K<>zk~cq%w7HWInc@fl-1uu z{vY=G5A(l-N5uL6GhkEyZHuC8v1PXoUsXe{&Q}$c_X;YzYRZSjl(&9Y)cA{wF5HhU zj9ql$7}15Xi!Pigx-fRpg@d9CcIHhTr72oHpsddBT<#USU)nn1&X)GWJofp`-FEry zK=uFeKSa1+s_%S;^BK-(IG^Es#)s)MR$odD_>7&;G*0lz$l7TT=QNzta8AQH4d*mI zAg5t&dB2mmU*(rDMDSiGu~iR<5{mabi7is_Jk(`r9UL4S&WV2jsh^k*08Rh^55LRg diff --git a/crates/meilisearch/tests/tasks/webhook.rs b/crates/meilisearch/tests/tasks/webhook.rs index 7fa088eb5..0990561e9 100644 --- a/crates/meilisearch/tests/tasks/webhook.rs +++ b/crates/meilisearch/tests/tasks/webhook.rs @@ -13,6 +13,7 @@ use meili_snap::{json_string, snapshot}; use meilisearch::Opt; use tokio::sync::mpsc; use url::Url; +use uuid::Uuid; use crate::common::{self, default_settings, Server}; use crate::json; @@ -129,16 +130,18 @@ async fn cli_only() { let (webhooks, code) = server.get_webhooks().await; snapshot!(code, @"200 OK"); - snapshot!(json_string!(webhooks, { ".webhooks._cli.url" => "[ignored]" }), @r#" + snapshot!(json_string!(webhooks, { ".results[].url" => "[ignored]" }), @r#" { - "webhooks": { - "_cli": { + "results": [ + { + "uuid": "00000000-0000-0000-0000-000000000000", + "isEditable": false, "url": "[ignored]", "headers": { "Authorization": "Bearer a-secret-token" } } - } + ] } "#); @@ -163,28 +166,36 @@ async fn cli_with_dumps() { snapshot!(code, @"200 OK"); snapshot!(webhooks, @r#" { - "webhooks": { - "_cli": { + "results": [ + { + "uuid": "00000000-0000-0000-0000-000000000000", + "isEditable": false, "url": "http://defined-in-test-cli.com/", "headers": { "Authorization": "Bearer a-secret-token-defined-in-test-cli" } }, - "exampleName": { + { + "uuid": "627ea538-733d-4545-8d2d-03526eb381ce", + "isEditable": true, + "url": "https://example.com/authorization-less", + "headers": {} + }, + { + "uuid": "771b0a28-ef28-4082-b984-536f82958c65", + "isEditable": true, "url": "https://example.com/hook", "headers": { "authorization": "TOKEN" } }, - "otherName": { - "url": "https://example.com/authorization-less", - "headers": {} - }, - "third": { + { + "uuid": "f3583083-f8a7-4cbf-a5e7-fb3f1e28a7e9", + "isEditable": true, "url": "https://third.com", "headers": {} } - } + ] } "#); } @@ -194,23 +205,23 @@ async fn reserved_names() { let server = Server::new().await; let (value, code) = server - .set_webhooks(json!({ "webhooks": { "_cli": { "url": "http://localhost:8080" } } })) + .set_webhooks(json!({ "webhooks": { Uuid::nil(): { "url": "http://localhost:8080" } } })) .await; snapshot!(code, @"400 Bad Request"); snapshot!(value, @r#" { - "message": "Cannot edit webhook `_cli`. Webhooks prefixed with an underscore are reserved and may not be modified using the API.", + "message": "Cannot edit webhook `[uuid]`. Webhooks prefixed with an underscore are reserved and may not be modified using the API.", "code": "reserved_webhook", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#reserved_webhook" } "#); - let (value, code) = server.set_webhooks(json!({ "webhooks": { "_cli": null } })).await; + let (value, code) = server.set_webhooks(json!({ "webhooks": { Uuid::nil(): null } })).await; snapshot!(code, @"400 Bad Request"); snapshot!(value, @r#" { - "message": "Cannot edit webhook `_cli`. Webhooks prefixed with an underscore are reserved and may not be modified using the API.", + "message": "Cannot edit webhook `[uuid]`. Webhooks prefixed with an underscore are reserved and may not be modified using the API.", "code": "reserved_webhook", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#reserved_webhook" @@ -223,14 +234,14 @@ async fn over_limits() { let server = Server::new().await; // Too many webhooks - for i in 0..20 { + for _ in 0..20 { let (_value, code) = server - .set_webhooks(json!({ "webhooks": { format!("webhook_{i}"): { "url": "http://localhost:8080" } } })) + .set_webhooks(json!({ "webhooks": { Uuid::new_v4(): { "url": "http://localhost:8080" } } })) .await; snapshot!(code, @"200 OK"); } let (value, code) = server - .set_webhooks(json!({ "webhooks": { "webhook_21": { "url": "http://localhost:8080" } } })) + .set_webhooks(json!({ "webhooks": { Uuid::new_v4(): { "url": "http://localhost:8080" } } })) .await; snapshot!(code, @"400 Bad Request"); snapshot!(value, @r#" @@ -252,20 +263,21 @@ async fn over_limits() { "#); // Test too many headers + let uuid = Uuid::new_v4(); for i in 0..200 { let header_name = format!("header_{i}"); let (_value, code) = server - .set_webhooks(json!({ "webhooks": { "webhook": { "url": "http://localhost:8080", "headers": { header_name: "value" } } } })) + .set_webhooks(json!({ "webhooks": { uuid: { "url": "http://localhost:8080", "headers": { header_name: "value" } } } })) .await; snapshot!(code, @"200 OK"); } let (value, code) = server - .set_webhooks(json!({ "webhooks": { "webhook": { "url": "http://localhost:8080", "headers": { "header_201": "value" } } } })) + .set_webhooks(json!({ "webhooks": { uuid: { "url": "http://localhost:8080", "headers": { "header_201": "value" } } } })) .await; snapshot!(code, @"400 Bad Request"); snapshot!(value, @r#" { - "message": "Too many headers for the webhook `webhook`. Please limit the number of headers to 200.", + "message": "Too many headers for the webhook `[uuid]`. Please limit the number of headers to 200.", "code": "invalid_webhooks_headers", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#invalid_webhooks_headers"