From: Simon Tatham Date: Fri, 5 Jan 2024 10:27:30 +0000 (+0000) Subject: Make all the tests compile again (ahem). X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=5c375740fcbf73525fa116f1bf127846d32fbd21;p=mastodonochrome.git Make all the tests compile again (ahem). --- diff --git a/src/editor.rs b/src/editor.rs index 967f7d8..6135de7 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -507,6 +507,8 @@ fn test_single_line_extra_ops() { }, width: 0, first_visible: 0, + prompt: ColouredString::plain(""), + promptwidth: 0, }; sle.cut_to_end(); @@ -535,6 +537,8 @@ fn test_single_line_visibility() { }, width: 5, first_visible: 0, + prompt: ColouredString::plain(""), + promptwidth: 0, }; assert_eq!(sle.draw(sle.width), @@ -803,7 +807,8 @@ impl Composer { #[cfg(test)] fn test_new(conf: InstanceStatusConfig, text: &str) -> Self { - Self::new(conf, FileHeader::new(ColouredString::plain("dummy")), text) + Self::new(conf, FileHeader::new(ColouredString::plain("dummy")), + None, Post::with_text(text)) } fn is_line_boundary(c: char) -> bool { diff --git a/src/posting.rs b/src/posting.rs index 67f1fee..e720d83 100644 --- a/src/posting.rs +++ b/src/posting.rs @@ -48,6 +48,19 @@ impl Post { } } + #[cfg(test)] + pub fn with_text(text: &str) -> Self { + Post { + text: text.to_owned(), + m: PostMetadata { + in_reply_to_id: None, + visibility: Visibility::Public, + content_warning: None, + language: default_language(), + }, + } + } + pub fn reply_to(id: &str, client: &mut Client) -> Result { diff --git a/src/text.rs b/src/text.rs index 8d2d391..fde9cdc 100644 --- a/src/text.rs +++ b/src/text.rs @@ -1133,8 +1133,8 @@ fn test_notification_log() { )); assert_eq!(NotificationLog::new( - t, "foo@example.com", "Foo Bar", "123", None, - NotificationType::Reblog, Some(&post)).render(80), vec! { + t, "foo@example.com", "Foo Bar", "123", + NotificationType::Reblog, Some(&post), None).render(80), vec! { ColouredString::general("Fri Aug 3 04:05:06 2001 Foo Bar (foo@example.com) boosted: take a look at this", " "), ColouredString::general(" otter! @badger might also like it", @@ -1142,8 +1142,8 @@ fn test_notification_log() { }); assert_eq!(NotificationLog::new( - t, "foo@example.com", "Foo Bar", "123", None, - NotificationType::Favourite, Some(&post)).render(51), vec! { + t, "foo@example.com", "Foo Bar", "123", + NotificationType::Favourite, Some(&post), None).render(51), vec! { ColouredString::general("Fri Aug 3 04:05:06 2001 Foo Bar (foo@example.com)", " "), ColouredString::general(" favourited: take a look at this otter! @badger...", @@ -1151,8 +1151,8 @@ fn test_notification_log() { }); assert_eq!(NotificationLog::new( - t, "foo@example.com", "Foo Bar", "123", None, - NotificationType::Follow, None).render(80), vec! { + t, "foo@example.com", "Foo Bar", "123", + NotificationType::Follow, None, None).render(80), vec! { ColouredString::general("Fri Aug 3 04:05:06 2001 Foo Bar (foo@example.com) followed you", " "), }); @@ -1212,7 +1212,7 @@ impl TextFragment for UserListEntry { #[test] fn test_user_list_entry() { - assert_eq!(UserListEntry::new("foo@example.com", "Foo Bar") + assert_eq!(UserListEntry::new("foo@example.com", "Foo Bar", "123") .render(80), vec! { ColouredString::general("Foo Bar (foo@example.com)", " "),