Feature request: provide mock capability for operator
Feature Description
Hi team, I'm now heavily use opendal in my work, I'm wondering if it's possible to provide a mock Operator, so I could easily mock in my unit test for error testing?
I did some searches in the codebase, I find we do use mock-based unit tests for retry test: https://github.com/apache/opendal/blob/faf12983a0f46a5c75641d1a0b0eaa5d0600b972/core/src/layers/retry.rs#L807-L1026
But that seems awkward and bespoke, I'm wondering if we could use mockall to decorate the trait, which unblocks full control for mock.
Problem and Solution
use mockall::*;
use mockall::predicate::*;
#[automock]
trait Operator {
/// interface functions
}
Additional Context
No response
Are you willing to contribute to the development of this feature?
- [ ] Yes, I am willing to contribute to the development of this feature.
Thank you for bringing this up. I think it could be interesting to provide such a mock.
To clarify, Operator is a struct, not a trait. It provides public APIs based on those offered by raw::Access.
There are two possible approaches: implementing a mock layer or implementing a mock service. Which option would better suit your use case?