Slide 6
Slide 6 text
Rust
のテストコード事始め 6
derive(Clone)
を実装しているstruct
はautomock
できなので、Clone
を実装しているStruct
は、下記のように
mock!
で囲む必要がある
mock! {
pub HttpClient {
pub(crate) async fn get_access_token(&self, body: String) -> anyhow::Result;
pub(crate) async fn get_folder_items(&self, url: &String, access_token: &String) -> anyhow::Result;
pub(crate) async fn post_sms_request(&self, body: String) -> anyhow::Result;
pub(crate) async fn download_file(&self, url: &String, access_token: &String) -> anyhow::Result>;
}
impl Clone for HttpClient {
fn clone(&self) -> Self;
}
}
なぜかtest
環境だけでderive(Dummy)
を有効にしていると、tokio::test
ではfake
を作成できなかった