Skip to content

UnitTest: make SimpleCacheClient mockable #150

@ymwjbxxq

Description

@ymwjbxxq

Hello Team,

It is impossible to Mock or create a Fake of the SimpleCacheClient (at least for me).

The client is initialised in this way:

    let credential_provider =
        CredentialProviderBuilder::from_environment_variable("MOMENTO_AUTH_TOKEN".to_string())
            .build()?;
    let cache_client =
        SimpleCacheClientBuilder::new(credential_provider, Duration::from_secs(500))?
            .build();

When writing code, you should be able to Mock the client or replace it.

If you create a trait with https://crates.io/crates/async-trait, it is possible to replace it or Mock it with a library like https://crates.io/crates/mockall.

With this, the code is testable if you write integration tests that are pretty expensive to run each time.

Thanks,

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions