ibis/tests/test.rs

42 lines
1018 B
Rust
Raw Normal View History

2023-11-15 12:05:07 +00:00
extern crate fediwiki;
2023-11-16 09:25:54 +00:00
use fediwiki::error::MyResult;
2023-11-15 12:05:07 +00:00
use fediwiki::federation::objects::article::DbArticle;
use fediwiki::start;
#[tokio::test]
2023-11-16 09:25:54 +00:00
async fn test_get_article() -> MyResult<()> {
2023-11-15 12:05:07 +00:00
let hostname = "localhost:8131";
2023-11-15 14:07:02 +00:00
let handle = tokio::task::spawn(async {
2023-11-15 12:05:07 +00:00
start(hostname).await.unwrap();
});
let title = "Manu_Chao";
let res: DbArticle = reqwest::get(format!("http://{hostname}/api/v1/article/{title}"))
2023-11-16 09:25:54 +00:00
.await?
2023-11-15 12:05:07 +00:00
.json()
2023-11-16 09:25:54 +00:00
.await?;
2023-11-15 12:05:07 +00:00
assert_eq!(title, res.title);
assert!(res.local);
2023-11-15 14:07:02 +00:00
handle.abort();
2023-11-16 09:25:54 +00:00
Ok(())
2023-11-15 12:05:07 +00:00
}
2023-11-15 14:07:02 +00:00
#[tokio::test]
2023-11-16 09:25:54 +00:00
async fn test_follow_instance() -> MyResult<()> {
2023-11-15 14:07:02 +00:00
let hostname_alpha = "localhost:8131";
let hostname_beta = "localhost:8132";
let handle_alpha = tokio::task::spawn(async {
start(hostname_alpha).await.unwrap();
});
let handle_beta = tokio::task::spawn(async {
start(hostname_beta).await.unwrap();
});
2023-11-16 09:25:54 +00:00
// TODO
2023-11-15 14:07:02 +00:00
handle_alpha.abort();
handle_beta.abort();
2023-11-16 09:25:54 +00:00
Ok(())
}