diff --git a/src/location.rs b/src/location.rs index ab3549516..dc07181ec 100644 --- a/src/location.rs +++ b/src/location.rs @@ -924,4 +924,38 @@ Content-Disposition: attachment; filename="location.kml" assert_eq!(locations.len(), 1); Ok(()) } + + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + async fn test_send_locations_to_chat() -> Result<()> { + let alice = TestContext::new_alice().await; + let bob = TestContext::new_bob().await; + + let alice_chat = alice.create_chat(&bob).await; + send_locations_to_chat(&alice, alice_chat.id, 1000).await?; + let sent = alice.pop_sent_msg().await; + let msg = bob.recv_msg(&sent).await; + assert_eq!(msg.text, "Location streaming enabled by alice@example.org."); + let bob_chat_id = msg.chat_id; + + assert_eq!(set(&alice, 10.0, 20.0, 1.0).await?, true); + + // Send image without text. + let file_name = "image.png"; + let bytes = include_bytes!("../test-data/image/logo.png"); + let file = alice.get_blobdir().join(file_name); + tokio::fs::write(&file, bytes).await?; + let mut msg = Message::new(Viewtype::Image); + msg.set_file(file.to_str().unwrap(), None); + let sent = alice.send_msg(alice_chat.id, &mut msg).await; + + let msg = bob.recv_msg_opt(&sent).await.unwrap(); + assert!(msg.chat_id == bob_chat_id); + assert_eq!(msg.msg_ids.len(), 1); + + let bob_msg = Message::load_from_db(&bob, *msg.msg_ids.get(0).unwrap()).await?; + assert_eq!(bob_msg.chat_id, bob_chat_id); + assert_eq!(bob_msg.viewtype, Viewtype::Image); + + Ok(()) + } }