refactor: extract inline test modules to separate files
This commit is contained in:
@@ -58,24 +58,4 @@ impl ThoughtNote {
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn note_serializes_with_public_audience() {
|
||||
let note = ThoughtNote::new_public(
|
||||
"https://example.com/thoughts/1".parse().unwrap(),
|
||||
"https://example.com/users/alice".parse().unwrap(),
|
||||
"Hello world".to_string(),
|
||||
chrono::Utc::now(),
|
||||
None,
|
||||
false,
|
||||
None,
|
||||
"https://example.com/users/alice/followers".parse().unwrap(),
|
||||
);
|
||||
let json = serde_json::to_string(¬e).unwrap();
|
||||
assert!(json.contains(AS_PUBLIC));
|
||||
assert!(json.contains("Hello world"));
|
||||
assert!(json.contains("\"url\""));
|
||||
}
|
||||
}
|
||||
mod tests;
|
||||
19
crates/adapters/activitypub/src/note/tests.rs
Normal file
19
crates/adapters/activitypub/src/note/tests.rs
Normal file
@@ -0,0 +1,19 @@
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn note_serializes_with_public_audience() {
|
||||
let note = ThoughtNote::new_public(
|
||||
"https://example.com/thoughts/1".parse().unwrap(),
|
||||
"https://example.com/users/alice".parse().unwrap(),
|
||||
"Hello world".to_string(),
|
||||
chrono::Utc::now(),
|
||||
None,
|
||||
false,
|
||||
None,
|
||||
"https://example.com/users/alice/followers".parse().unwrap(),
|
||||
);
|
||||
let json = serde_json::to_string(¬e).unwrap();
|
||||
assert!(json.contains(AS_PUBLIC));
|
||||
assert!(json.contains("Hello world"));
|
||||
assert!(json.contains("\"url\""));
|
||||
}
|
||||
@@ -33,25 +33,4 @@ impl ThoughtsUrls {
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn user_url_format() {
|
||||
let urls = ThoughtsUrls::new("https://example.com");
|
||||
assert_eq!(
|
||||
urls.user_url("alice").as_str(),
|
||||
"https://example.com/users/alice"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn thought_url_format() {
|
||||
let urls = ThoughtsUrls::new("https://example.com");
|
||||
let id = uuid::Uuid::nil();
|
||||
assert!(urls
|
||||
.thought_url(id)
|
||||
.as_str()
|
||||
.starts_with("https://example.com/thoughts/"));
|
||||
}
|
||||
}
|
||||
mod tests;
|
||||
20
crates/adapters/activitypub/src/urls/tests.rs
Normal file
20
crates/adapters/activitypub/src/urls/tests.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn user_url_format() {
|
||||
let urls = ThoughtsUrls::new("https://example.com");
|
||||
assert_eq!(
|
||||
urls.user_url("alice").as_str(),
|
||||
"https://example.com/users/alice"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn thought_url_format() {
|
||||
let urls = ThoughtsUrls::new("https://example.com");
|
||||
let id = uuid::Uuid::nil();
|
||||
assert!(urls
|
||||
.thought_url(id)
|
||||
.as_str()
|
||||
.starts_with("https://example.com/thoughts/"));
|
||||
}
|
||||
Reference in New Issue
Block a user