2023-05-27 10:52:15 +00:00
|
|
|
mod it_test {
|
|
|
|
use model::{
|
|
|
|
entity::{antenna, user},
|
|
|
|
repository::Repository,
|
|
|
|
schema,
|
|
|
|
};
|
|
|
|
use sea_orm::{ColumnTrait, EntityTrait, QueryFilter};
|
2023-05-27 09:50:07 +00:00
|
|
|
|
2023-05-27 10:52:15 +00:00
|
|
|
use crate::{cleanup, prepare};
|
2023-05-27 09:50:07 +00:00
|
|
|
|
2023-05-27 10:52:15 +00:00
|
|
|
#[tokio::test]
|
|
|
|
async fn can_pack() {
|
|
|
|
prepare().await;
|
|
|
|
let db = database::get_database().unwrap();
|
2023-05-27 09:50:07 +00:00
|
|
|
|
2023-05-27 10:52:15 +00:00
|
|
|
let alice_antenna = user::Entity::find()
|
|
|
|
.filter(user::Column::Username.eq("alice"))
|
|
|
|
.find_also_related(antenna::Entity)
|
|
|
|
.one(db)
|
|
|
|
.await
|
|
|
|
.unwrap()
|
|
|
|
.expect("alice not found")
|
|
|
|
.1
|
|
|
|
.expect("alice's antenna not found");
|
2023-05-27 09:50:07 +00:00
|
|
|
|
2023-05-27 10:52:15 +00:00
|
|
|
let packed = alice_antenna
|
|
|
|
.to_owned()
|
|
|
|
.pack()
|
|
|
|
.await
|
|
|
|
.expect("Unable to pack");
|
2023-05-27 09:50:07 +00:00
|
|
|
|
2023-05-27 10:52:15 +00:00
|
|
|
assert_eq!(
|
|
|
|
packed,
|
|
|
|
schema::antenna::Antenna {
|
|
|
|
id: alice_antenna.id,
|
|
|
|
created_at: alice_antenna.created_at.into(),
|
|
|
|
name: "Test Antenna".to_string(),
|
|
|
|
keywords: vec![
|
|
|
|
vec!["foo".to_string(), "bar".to_string()],
|
|
|
|
vec!["foobar".to_string()]
|
2023-05-31 16:09:30 +00:00
|
|
|
]
|
|
|
|
.into(),
|
2023-05-27 10:52:15 +00:00
|
|
|
exclude_keywords: vec![
|
|
|
|
vec!["abc".to_string()],
|
|
|
|
vec!["def".to_string(), "ghi".to_string()]
|
2023-05-31 16:09:30 +00:00
|
|
|
]
|
|
|
|
.into(),
|
2023-05-27 10:52:15 +00:00
|
|
|
src: schema::antenna::AntennaSrc::All,
|
|
|
|
user_list_id: None,
|
|
|
|
user_group_id: None,
|
2023-05-31 16:09:30 +00:00
|
|
|
users: vec![].into(),
|
|
|
|
instances: vec![].into(),
|
2023-05-27 10:52:15 +00:00
|
|
|
case_sensitive: true,
|
|
|
|
notify: true,
|
|
|
|
with_replies: false,
|
|
|
|
with_file: false,
|
|
|
|
has_unread_note: false,
|
|
|
|
}
|
|
|
|
);
|
2023-05-27 09:50:07 +00:00
|
|
|
|
2023-05-27 10:52:15 +00:00
|
|
|
cleanup().await;
|
|
|
|
}
|
2023-05-27 11:02:10 +00:00
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn unread_note() {
|
|
|
|
todo!();
|
|
|
|
}
|
2023-05-27 09:50:07 +00:00
|
|
|
}
|