Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add test for optimistic locking and fix it #81

Merged
merged 1 commit into from
Mar 15, 2024

Conversation

ctron
Copy link
Contributor

@ctron ctron commented Mar 15, 2024

The reason for updating to Rust 1.76.0 was the introduction of inspect_err, which I find super helpful (also in this case):

operation().
    .inspect_err(|err| {
        log::info!("err: {err:?}");
    })

@ctron ctron force-pushed the feature/import_4b branch 2 times, most recently from f66c9d5 to ef6cb08 Compare March 15, 2024 15:46
Copy link
Contributor

@jcrossley3 jcrossley3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expected to see inspect_err called somewhere in here. 😄

use serde_json::json;
use trustify_common::db::Database;

#[actix_web::test]
async fn test_default() {
env_logger::init();
let _ = env_logger::try_init();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious why this is better?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because otherwise tests will fail. Having init will run that methods twice (for two different tests) and the second one will fail. That's why the CI just failed, because the logger was already initialized by the first test.

@ctron
Copy link
Contributor Author

ctron commented Mar 15, 2024

I expected to see inspect_err called somewhere in here. 😄

I used that, but just for debugging. I removed it afterwards.

However, it allows one to more easily inject that into the call flow. Vs ripping it out and handling it with a match or if.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants