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

Move test helper to make it useable in other tests #1762

Merged
merged 1 commit into from
Jul 31, 2023

Conversation

frederikrothenberger
Copy link
Contributor

@frederikrothenberger frederikrothenberger commented Jul 28, 2023

Creating new identities based off authn_methods will be requiered in almost all v2 API integration tests. This PR moves it into a helper file where it can be used from any other test.


🟡 Some screens were changed

Creating new identities based off authn_methods will be requiered
in almost all v2 API integration tests. This PR moves it into a helper
file where it can be used from any other test.
Copy link
Contributor

@dskloetd dskloetd left a comment

Choose a reason for hiding this comment

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

Why does the PR description say some screens were changed?

pub fn create_identity_with_authn_method(
env: &StateMachine,
canister_id: CanisterId,
authn_method: &AuthnMethodData,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this now passed by reference while before it wasn't?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Having the function only borrow the argument allows tests to use it multiple times. This moves the call to clone into the function making the tests less cluttered.

Copy link
Contributor

Choose a reason for hiding this comment

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

None of the tests seem to be using the argument multiple times, nor calling clone. Am I missing something?

Is this change related to the moving the helper or orthogonal?

Is it needed/used by your follow-up/main PR?

Copy link
Contributor Author

@frederikrothenberger frederikrothenberger Jul 31, 2023

Choose a reason for hiding this comment

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

None of the tests seem to be using the argument multiple times, nor calling clone. Am I missing something?

I think so? There is a line diff in src/internet_identity/tests/integration/v2_api/authn_method_add.rs that changes

let identity_number = create_identity_with_authn_method(&env, canister_id, authn_method.clone());

to

let identity_number = create_identity_with_authn_method(&env, canister_id, &authn_method);

Similarly in the upcoming changeset.

Is this change related to the moving the helper or orthogonal?

It does not directly have anything to do with moving, but goes in the same vein as it also makes the helper more useful (imho).

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, yes, I missed it.

It does mean that clone is now called more often than before, right? Does that go against the spirit or Rust? Anyway it's fine.

@frederikrothenberger
Copy link
Contributor Author

Why does the PR description say some screens were changed?

There seems to be some flakyness regarding the screenshots. I will talk to @nmattia about that, since there have been a lot of changes to that infrastructure since I went on PTO.

pub fn create_identity_with_authn_method(
env: &StateMachine,
canister_id: CanisterId,
authn_method: &AuthnMethodData,
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, yes, I missed it.

It does mean that clone is now called more often than before, right? Does that go against the spirit or Rust? Anyway it's fine.

@frederikrothenberger frederikrothenberger added this pull request to the merge queue Jul 31, 2023
@frederikrothenberger
Copy link
Contributor Author

It does mean that clone is now called more often than before, right? Does that go against the spirit or Rust?

Potentially yes. However, in most cases clone was called anyway (because the argument needed to be still available later). Also the integration tests are definitely not constrained by clone. 😉
In this case, for better readability, I prefer simplifying the test code as much as possible even if it results in a few additional clones.

Merged via the queue into main with commit d6851f6 Jul 31, 2023
46 checks passed
@frederikrothenberger frederikrothenberger deleted the frederik/move-test-helper branch July 31, 2023 07:20
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