From d3e0d38bef3a6738c445c0178387234a31d407a7 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 7 Jun 2023 15:24:08 +0200 Subject: [PATCH] Fix assistant panel tests --- crates/ai/src/assistant.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index 1a6da539fa..77353e1ee4 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -1365,16 +1365,18 @@ mod tests { cx.add_model(|cx| { let mut assistant = Assistant::new(Default::default(), registry, cx); - let message_1 = assistant.insert_message_after(ExcerptId::max(), Role::Assistant, cx); - let message_2 = assistant.insert_message_after(message_1.excerpt_id, Role::User, cx); - let message_3 = assistant.insert_message_after(message_1.excerpt_id, Role::User, cx); + let message_1 = assistant.messages[0].clone(); + let message_2 = assistant.insert_message_after(ExcerptId::max(), Role::Assistant, cx); + let message_3 = assistant.insert_message_after(message_2.excerpt_id, Role::User, cx); + let message_4 = assistant.insert_message_after(message_2.excerpt_id, Role::User, cx); assistant.remove_empty_messages( - HashSet::from_iter([message_2.excerpt_id, message_3.excerpt_id]), + HashSet::from_iter([message_3.excerpt_id, message_4.excerpt_id]), Default::default(), cx, ); - assert_eq!(assistant.messages.len(), 1); + assert_eq!(assistant.messages.len(), 2); assert_eq!(assistant.messages[0].excerpt_id, message_1.excerpt_id); + assert_eq!(assistant.messages[1].excerpt_id, message_2.excerpt_id); assistant }); }