init
Some checks failed
CI / ci (push) Failing after 1m48s

This commit is contained in:
2026-08-25 23:24:36 +02:00
commit 95739892de
466 changed files with 33918 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
use domain::attachment::ContentType;
use domain::errors::DomainError;
#[test]
fn valid_content_type_is_created() {
let ct = ContentType::new("image/jpeg").unwrap();
assert_eq!(ct.value(), "image/jpeg");
}
#[test]
fn content_type_is_lowercased() {
let ct = ContentType::new("Image/JPEG").unwrap();
assert_eq!(ct.value(), "image/jpeg");
}
#[test]
fn content_type_trims_whitespace() {
let ct = ContentType::new(" audio/webm ").unwrap();
assert_eq!(ct.value(), "audio/webm");
}
#[test]
fn empty_content_type_is_rejected() {
let result = ContentType::new("");
assert!(matches!(result, Err(DomainError::InvalidInput(_))));
}
#[test]
fn content_type_without_slash_is_rejected() {
let result = ContentType::new("jpeg");
assert!(matches!(result, Err(DomainError::InvalidInput(_))));
}
#[test]
fn from_persistence_bypasses_validation() {
let ct = ContentType::from_persistence(String::new());
assert_eq!(ct.value(), "");
}

View File

@@ -0,0 +1,19 @@
use domain::attachment::{ContentType, MediaUpload};
use domain::errors::DomainError;
#[test]
fn valid_upload_is_created() {
let ct = ContentType::new("image/png").unwrap();
let upload = MediaUpload::new(vec![1, 2, 3], ct).unwrap();
assert_eq!(upload.data(), &[1, 2, 3]);
assert_eq!(upload.content_type().value(), "image/png");
assert_eq!(upload.size(), 3);
}
#[test]
fn empty_data_is_rejected() {
let ct = ContentType::new("image/png").unwrap();
let result = MediaUpload::new(vec![], ct);
assert!(matches!(result, Err(DomainError::InvalidInput(_))));
}