From 84cd5cef0b8628c8fd77481509a3213091740d04 Mon Sep 17 00:00:00 2001 From: Tamo Date: Mon, 26 Sep 2022 14:56:08 +0200 Subject: [PATCH] fix the tests --- Cargo.lock | 60 ++++++++++++++++++++++++-- index-scheduler/Cargo.toml | 2 +- index-scheduler/src/index_scheduler.rs | 21 ++++++++- 3 files changed, 77 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fe72086c6..88e9b64b2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1036,9 +1036,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f91d4cfa921f1c05904dc3c57b4a32c38aed3340cce209f3a6fd1478babafc4" dependencies = [ "darling", - "proc-macro2 1.0.39", - "quote 1.0.18", - "syn 1.0.96", + "proc-macro2 1.0.46", + "quote 1.0.21", + "syn 1.0.101", ] [[package]] @@ -1048,7 +1048,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f0314b72bed045f3a68671b3c86328386762c93f82d98c65c3cb5e5f573dd68" dependencies = [ "derive_builder_core", - "syn 1.0.96", + "syn 1.0.101", ] [[package]] @@ -1865,6 +1865,8 @@ dependencies = [ "console", "lazy_static", "linked-hash-map", + "pest", + "pest_derive", "serde", "similar", "yaml-rust", @@ -2921,6 +2923,50 @@ dependencies = [ "serde_json", ] +[[package]] +name = "pest" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbc7bc69c062e492337d74d59b120c274fd3d261b6bf6d3207d499b4b379c41a" +dependencies = [ + "thiserror", + "ucd-trie", +] + +[[package]] +name = "pest_derive" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b75706b9642ebcb34dab3bc7750f811609a0eb1dd8b88c2d15bf628c1c65b2" +dependencies = [ + "pest", + "pest_generator", +] + +[[package]] +name = "pest_generator" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f9272122f5979a6511a749af9db9bfc810393f63119970d7085fed1c4ea0db" +dependencies = [ + "pest", + "pest_meta", + "proc-macro2 1.0.46", + "quote 1.0.21", + "syn 1.0.101", +] + +[[package]] +name = "pest_meta" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8717927f9b79515e565a64fe46c38b8cd0427e64c40680b14a7365ab09ac8d" +dependencies = [ + "once_cell", + "pest", + "sha1", +] + [[package]] name = "phf" version = "0.11.1" @@ -4033,6 +4079,12 @@ version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" +[[package]] +name = "ucd-trie" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" + [[package]] name = "unicase" version = "2.6.0" diff --git a/index-scheduler/Cargo.toml b/index-scheduler/Cargo.toml index 6854dbee8..1b2818f00 100644 --- a/index-scheduler/Cargo.toml +++ b/index-scheduler/Cargo.toml @@ -26,5 +26,5 @@ derive_builder = "0.11.2" [dev-dependencies] nelson = { git = "https://github.com/meilisearch/nelson.git", rev = "675f13885548fb415ead8fbb447e9e6d9314000a"} -insta = { version = "1.19.1", features = ["json"] } +insta = { version = "1.19.1", features = ["json", "redactions"] } big_s = "1.0.2" diff --git a/index-scheduler/src/index_scheduler.rs b/index-scheduler/src/index_scheduler.rs index be9a4ae46..b6b256ddb 100644 --- a/index-scheduler/src/index_scheduler.rs +++ b/index-scheduler/src/index_scheduler.rs @@ -477,7 +477,26 @@ mod tests { index_scheduler.tick().unwrap(); let task = index_scheduler.get_tasks(Query::default()).unwrap(); - assert_smol_debug_snapshot!(task, @r###"[TaskView { uid: 0, index_uid: Some("doggos"), status: Succeeded, kind: DocumentAddition, details: Some(DocumentAddition { received_documents: 1, indexed_documents: 1 }), error: None, duration: Some(Duration { seconds: 0, nanoseconds: 29654837 }), enqueued_at: OffsetDateTime { local_datetime: PrimitiveDateTime { date: Date { year: 2022, ordinal: 269 }, time: Time { hour: 11, minute: 34, second: 29, nanosecond: 202925184 } }, offset: UtcOffset { hours: 0, minutes: 0, seconds: 0 } }, started_at: Some(OffsetDateTime { local_datetime: PrimitiveDateTime { date: Date { year: 2022, ordinal: 269 }, time: Time { hour: 11, minute: 34, second: 29, nanosecond: 203190739 } }, offset: UtcOffset { hours: 0, minutes: 0, seconds: 0 } }), finished_at: Some(OffsetDateTime { local_datetime: PrimitiveDateTime { date: Date { year: 2022, ordinal: 269 }, time: Time { hour: 11, minute: 34, second: 29, nanosecond: 232845576 } }, offset: UtcOffset { hours: 0, minutes: 0, seconds: 0 } }) }]"###); + assert_json_snapshot!(task, + { "[].enqueuedAt" => "date", "[].startedAt" => "date", "[].finishedAt" => "date", "[].duration" => "duration" } + ,@r###" + [ + { + "uid": 0, + "indexUid": "doggos", + "status": "succeeded", + "type": "documentAddition", + "details": { + "receivedDocuments": 1, + "indexedDocuments": 1 + }, + "duration": "duration", + "enqueuedAt": "date", + "startedAt": "date", + "finishedAt": "date" + } + ] + "###); let doggos = index_scheduler.index("doggos").unwrap();