dagger-components/crates/cuddle-ci/src/rust_service/clap_sanity_test.rs
kjuulh bda242422d
Some checks failed
continuous-integration/drone/push Build is failing
feat: with arc
Signed-off-by: kjuulh <contact@kjuulh.io>
2023-11-27 20:11:49 +01:00

44 lines
923 B
Rust

use std::sync::Arc;
use async_trait::async_trait;
use dagger_sdk::Container;
use crate::dagger_middleware::DaggerMiddleware;
use super::RustService;
pub struct ClapSanityTest {
bin_name: String,
}
impl ClapSanityTest {
pub fn new(bin_name: impl Into<String>) -> Self {
Self {
bin_name: bin_name.into(),
}
}
}
#[async_trait]
impl DaggerMiddleware for ClapSanityTest {
async fn handle(&self, container: Container) -> eyre::Result<Container> {
Ok(container.with_exec(vec![&self.bin_name, "--help"]))
}
}
pub trait ClapSanityTestExt {
fn with_clap_sanity_test(&mut self) -> &mut Self {
self
}
}
impl ClapSanityTestExt for RustService {
fn with_clap_sanity_test(&mut self) -> &mut Self {
self.with_stage(super::RustServiceStage::AfterPackage(Arc::new(
ClapSanityTest::new(&self.bin_name),
)));
self
}
}