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

feat: CLI integration test improvements #754

Merged
merged 8 commits into from
Feb 25, 2025
Merged

Conversation

tomyrd
Copy link
Collaborator

@tomyrd tomyrd commented Feb 21, 2025

Based on some issues mentioned in #506. This PR simplifies the CLI tests by moving the command calling to functions that also read the output and return useful information so that it doesn't need to be retrieved again.

@tomyrd tomyrd added the no changelog This PR does not require an entry in the `CHANGELOG.md` file label Feb 25, 2025
@tomyrd tomyrd marked this pull request as ready for review February 25, 2025 14:34
Copy link
Collaborator

@igamigo igamigo left a comment

Choose a reason for hiding this comment

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

Nice! Looks much better. I left some comments but overall looks good to me!

@@ -150,6 +150,7 @@ impl SyncSummary {
self.consumed_notes.append(&mut other.consumed_notes);
self.updated_accounts.append(&mut other.updated_accounts);
self.locked_accounts.append(&mut other.locked_accounts);
self.committed_transactions.append(&mut other.committed_transactions);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, do we want to also add this to is_empty? Wonder if there is a better way to manage these

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, just realized about this error because I wanted to use that value. Seems we weren't checking on it on the other integration tests

(store_path, temp_dir)
}

fn init_cli_with_store_path(network: &str, store_path: &Path) -> PathBuf {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can init_test_without_params() also use these?

@@ -640,26 +380,135 @@ async fn test_init_with_testnet() {
assert!(config_file_str.contains(&Endpoint::testnet().to_string()));
}

#[tokio::test]
async fn debug_mode_outputs_logs() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we take the chance to document what this does briefly? Since it's fairly complex for something that may look simple


// Create a Client and a custom note
let store_path = create_test_store_path();
let (mut client, authenticator) = create_test_client_with_store_path(&store_path).await;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we could rename this function to something like create_rust_client_with_store_path in order to describe it better, but not too strong of an opinion so feel free to disregard

Comment on lines 460 to 468
// HELPERS
// ================================================================================================

fn init_cli(network: &str) -> (PathBuf, PathBuf) {
let store_path = create_test_store_path();
let temp_dir = init_cli_with_store_path(network, &store_path);

(store_path, temp_dir)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Some brief doc comments on helper functions would be great for future reference, even though most of these are simple, they are the library of functions that we should use to develop future tests.

Copy link
Collaborator

@igamigo igamigo left a comment

Choose a reason for hiding this comment

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

Thanks!

@igamigo igamigo merged commit eb7d7ab into next Feb 25, 2025
13 checks passed
@igamigo igamigo deleted the tomyrd-cli-test-improvements branch February 25, 2025 21:37
@igamigo igamigo mentioned this pull request Feb 25, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no changelog This PR does not require an entry in the `CHANGELOG.md` file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants