Change format_datetime implementation according to feature

This commit is contained in:
Kitaiti Makoto 2022-01-09 09:31:03 +09:00
parent 93a2c6d99f
commit 9c177f6286

View File

@ -950,6 +950,7 @@ mod tests {
use diesel::Connection; use diesel::Connection;
use serde_json::{json, to_value}; use serde_json::{json, to_value};
#[cfg(feature = "postgres")]
fn format_datetime(dt: &NaiveDateTime) -> String { fn format_datetime(dt: &NaiveDateTime) -> String {
format!( format!(
"{:04}-{:02}-{:02}T{:02}:{:02}:{:02}.{:06}Z", "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}.{:06}Z",
@ -963,6 +964,19 @@ mod tests {
) )
} }
#[cfg(feature = "sqlite")]
fn format_datetime(dt: &NaiveDateTime) -> String {
format!(
"{:04}-{:02}-{:02}T{:02}:{:02}:{:02}Z",
dt.year(),
dt.month(),
dt.day(),
dt.hour(),
dt.minute(),
dt.second()
)
}
fn prepare_activity(conn: &DbConn) -> (Post, Mention, Vec<Post>, Vec<User>, Vec<Blog>) { fn prepare_activity(conn: &DbConn) -> (Post, Mention, Vec<Post>, Vec<User>, Vec<Blog>) {
let (posts, users, blogs) = fill_database(conn); let (posts, users, blogs) = fill_database(conn);
let post = &posts[0]; let post = &posts[0];