test: add test for dc_get_abs_path()

This commit is contained in:
Lars-Magnus Skog
2019-06-07 21:03:30 +02:00
parent e97f6acccd
commit a1e790b91b
+18
View File
@@ -2,6 +2,7 @@
use std::collections::HashSet;
use std::ffi::{CStr, CString};
use std::path::PathBuf;
use mmime::mailimf_types::*;
use tempfile::{tempdir, TempDir};
@@ -945,6 +946,23 @@ fn test_dc_get_oauth2_token() {
assert_eq!(res, None);
}
#[test]
fn test_dc_get_abs_path() {
let ctx = unsafe { create_test_context() };
let blobdir_c = unsafe { dc_get_blobdir(&ctx.ctx) };
let mut image_path = PathBuf::from(to_string(blobdir_c));
image_path.push("image.png");
let mut image_path_2 = PathBuf::from("$BLOBDIR");
image_path_2.push("image.png");
let image_c = CString::new(image_path_2.to_str().unwrap()).unwrap();
let abs_path = unsafe { dc_get_abs_path(&ctx.ctx, image_c.as_ptr()) };
assert_eq!(to_string(abs_path), image_path.to_str().unwrap());
}
#[test]
fn test_stress_tests() {
unsafe {