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

Refactor config integration tests. #2785

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

sea-snake
Copy link
Contributor

@sea-snake sea-snake commented Jan 17, 2025

Refactor config integration tests to clarify what cases are covered, utility methods are implemented for repetitive checks e.g. assert config with config returned from query.


🟡 Some screens were changed

@sea-snake sea-snake requested a review from lmuntaner January 17, 2025 13:28
Copy link
Collaborator

@lmuntaner lmuntaner left a comment

Choose a reason for hiding this comment

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

Looks much nicer, thanks!

I added some comments.

assert_eq!(
api::config(env, canister_id)?,
InternetIdentityInit {
openid_google: expected_config.openid_google.clone().or(Some(None)),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this one necessary like this?

}

/// Utility method to upgrade with other config change and check if any other config hasn't changed
fn unrelated_change_and_assert(
Copy link
Collaborator

Choose a reason for hiding this comment

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

unrelated_change to what? To another config? Which other config? One with optionals?

)?;
assert_config(env, canister_id, &expected_config)?;
Ok(canister_id)
}

#[test]
fn should_retain_anchor_on_user_range_change() -> Result<(), CallError> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wasn't there something missing in this test? which Anchor is retained?


assert_eq!(api::config(&env, canister_id)?, config);
let canister_id = install_and_assert(&env, &config)?;
upgrade_ii_canister_with_arg(&env, canister_id, II_WASM.clone(), Some(config.clone()))?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this upgrade using None?


assert_eq!(api::config(&env, canister_id)?, config);
// Check if related origins are disabled and then untouched
let canister_id_2 = install_and_assert(&env, &config_1)?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are there different canister ids? Shouldn't they all be the same?

assert_eq!(api::config(&env, canister_id)?, config);
// Check if related origins are disabled and then untouched
let canister_id_2 = install_and_assert(&env, &config_1)?;
upgrade_and_assert(&env, canister_id_2, &disabled_config, &disabled_config)?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wouldn't it be better if the confi passed to upgrade_and_assert had mostly None fields except for the changes we are interested and then we expect the fields to be present from before?

If config logic substituted a None for some value, we wouldn't catch it here, right?

};
// Check if open id config is disabled and then untouched
let canister_id_2 = install_and_assert(&env, &config_1)?;
upgrade_and_assert(&env, canister_id_2, &disabled_config, &disabled_config)?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ditto as before

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