mirror of
https://github.com/chatmail/core.git
synced 2026-04-23 00:16:34 +03:00
adapt tests for new avatar recoding
This commit is contained in:
committed by
holger krekel
parent
a5f949c4e2
commit
435f734d60
@@ -191,6 +191,8 @@ mod tests {
|
|||||||
use std::string::ToString;
|
use std::string::ToString;
|
||||||
|
|
||||||
use crate::test_utils::*;
|
use crate::test_utils::*;
|
||||||
|
use std::fs::File;
|
||||||
|
use std::io::Write;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_to_string() {
|
fn test_to_string() {
|
||||||
@@ -210,16 +212,17 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_selfavatar() -> failure::Fallible<()> {
|
fn test_selfavatar_outside_blobdir() -> failure::Fallible<()> {
|
||||||
let t = dummy_context();
|
let t = dummy_context();
|
||||||
let avatar_src = t.dir.path().join("avatar.jpg");
|
let avatar_src = t.dir.path().join("avatar.jpg");
|
||||||
std::fs::write(&avatar_src, b"avatar")?;
|
let avatar_bytes = include_bytes!("../test-data/image/avatar1000x1000.jpg");
|
||||||
|
File::create(&avatar_src)?.write_all(avatar_bytes)?;
|
||||||
let avatar_blob = t.ctx.get_blobdir().join("avatar.jpg");
|
let avatar_blob = t.ctx.get_blobdir().join("avatar.jpg");
|
||||||
assert!(!avatar_blob.exists());
|
assert!(!avatar_blob.exists());
|
||||||
t.ctx
|
t.ctx
|
||||||
.set_config(Config::Selfavatar, Some(&avatar_src.to_str().unwrap()))?;
|
.set_config(Config::Selfavatar, Some(&avatar_src.to_str().unwrap()))?;
|
||||||
assert!(avatar_blob.exists());
|
assert!(avatar_blob.exists());
|
||||||
assert_eq!(std::fs::read(&avatar_blob)?, b"avatar");
|
assert!(std::fs::metadata(&avatar_blob).unwrap().len() < avatar_bytes.len() as u64);
|
||||||
let avatar_cfg = t.ctx.get_config(Config::Selfavatar);
|
let avatar_cfg = t.ctx.get_config(Config::Selfavatar);
|
||||||
assert_eq!(avatar_cfg, avatar_blob.to_str().map(|s| s.to_string()));
|
assert_eq!(avatar_cfg, avatar_blob.to_str().map(|s| s.to_string()));
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -229,7 +232,8 @@ mod tests {
|
|||||||
fn test_selfavatar_in_blobdir() -> failure::Fallible<()> {
|
fn test_selfavatar_in_blobdir() -> failure::Fallible<()> {
|
||||||
let t = dummy_context();
|
let t = dummy_context();
|
||||||
let avatar_src = t.ctx.get_blobdir().join("avatar.jpg");
|
let avatar_src = t.ctx.get_blobdir().join("avatar.jpg");
|
||||||
std::fs::write(&avatar_src, b"avatar")?;
|
let avatar_bytes = include_bytes!("../test-data/image/avatar1000x1000.jpg");
|
||||||
|
File::create(&avatar_src)?.write_all(avatar_bytes)?;
|
||||||
t.ctx
|
t.ctx
|
||||||
.set_config(Config::Selfavatar, Some(&avatar_src.to_str().unwrap()))?;
|
.set_config(Config::Selfavatar, Some(&avatar_src.to_str().unwrap()))?;
|
||||||
let avatar_cfg = t.ctx.get_config(Config::Selfavatar);
|
let avatar_cfg = t.ctx.get_config(Config::Selfavatar);
|
||||||
|
|||||||
BIN
test-data/image/avatar1000x1000.jpg
Normal file
BIN
test-data/image/avatar1000x1000.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 35 KiB |
Reference in New Issue
Block a user