feat: add tests

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2024-02-18 11:39:02 +01:00
parent 44fbf1f362
commit e994df19cf
4 changed files with 83 additions and 20 deletions

View File

@@ -0,0 +1,48 @@
struct Server {}
impl Server {
pub async fn new() -> Self {
Self {}
}
pub async fn start(&self) -> anyhow::Result<()> {
Ok(())
}
}
static INIT: std::sync::Once = std::sync::Once::new();
// Makes sure the setup is ready for execution
async fn is_ready() -> anyhow::Result<()> {
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
Ok(())
}
async fn setup() -> anyhow::Result<()> {
INIT.call_once(|| {
tokio::spawn(async move {
println!("once was created once");
Server::new().await.start().await.unwrap();
});
});
is_ready().await?;
Ok(())
}
#[tokio::test]
async fn can_create_artifact() -> anyhow::Result<()> {
setup().await?;
anyhow::bail!("failed one");
Ok(())
}
#[tokio::test]
async fn can_more_create_artifact() -> anyhow::Result<()> {
setup().await?;
anyhow::bail!("failed two");
Ok(())
}