Add Rust clone of python `prepare_and_send' test

Previous version of patch, that changed type of `dc_msg_t.text' to String had
been breaking `prepare_and_send' test in Python.

This commit adds same regression test, reimplemented in Rust, since running
Rust tests is simplier and faster.
This commit is contained in:
Dmitry Bogatov
2019-08-04 13:34:42 +00:00
committed by Floris Bruynooghe
parent 4d9bd46c9d
commit d4650ba4a9

View File

@@ -1426,6 +1426,7 @@ pub fn dc_update_server_uid(
#[cfg(test)]
mod tests {
use super::*;
use crate::test_utils as test;
use std::ffi::CStr;
#[test]
@@ -1546,4 +1547,36 @@ mod tests {
free(mime_0 as *mut libc::c_void);
}
}
#[test]
pub fn test_prepare_message_and_send() {
use crate::config::Config;
unsafe {
let d = test::dummy_context();
let ctx = &d.ctx;
let contact = dc_create_contact(
ctx,
b"\x00".as_ptr().cast(),
b"dest@example.com\x00".as_ptr().cast(),
);
assert!(contact != 0);
let res = ctx.set_config(Config::ConfiguredAddr, Some("self@example.com"));
assert!(res.is_ok());
let chat = dc_create_chat_by_contact_id(ctx, contact);
assert!(chat != 0);
let msg = dc_msg_new(ctx, Viewtype::Text);
assert!(!msg.is_null());
let msg_id = dc_prepare_msg(ctx, chat, msg);
assert!(msg_id != 0);
let msg2 = dc_get_msg(ctx, msg_id);
assert!(!msg2.is_null());
}
}
}