Skip to content

Add integration tests for basic interactions with most of the commands #1181

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

Merged
merged 16 commits into from
Apr 11, 2022

Conversation

kamilogorek
Copy link
Contributor

image

@kamilogorek kamilogorek requested a review from AbhiPrasad April 8, 2022 15:26
Copy link
Member

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

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

Nice, good changes!

here/api__0.json Outdated
@@ -0,0 +1 @@
{"version":"0","auth":null,"user":null}
Copy link
Member

Choose a reason for hiding this comment

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

where is this being generated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops. Removed.

src/api.rs Outdated
debug!("body: {}", body);

// Internal helper for making it easier to write integration tests.
if let Ok(dir) = env::var("SENTRY_DUMP") {
Copy link
Member

Choose a reason for hiding this comment

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

do we need to document SENTRY_DUMP? Also maybe we make the env variable more specific to sentry cli?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd not do that tbh. It's only a helper for me, to make writing tests for all existing commands easier. I might remove it in the future entirely. Added better comment, renamed it and handled errors.

@@ -37,6 +39,12 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
.unwrap_or("<unknown>")
);

// It's not currently possible to easily mock I/O with `trycmd`,
// but verifying that `execute` is not panicking, is good enough for now.
if env::var("TEST").is_ok() {
Copy link
Member

Choose a reason for hiding this comment

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

TEST is also pretty generalized, maybe we choose a more specific env variable name?

We should also debug log so it's clear why we are skipping the rest of execute.

This also applies to the rest of the usages of env::var("TEST")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

src/api.rs Outdated
@@ -1864,6 +1876,26 @@ fn log_headers(is_response: bool, data: &[u8]) {
}
}

fn dump_response(mut dir: String, url: &str, body: String) {
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't this return an error vs. emitting a panic that bubbles up?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated. (handle error only, not panic, as this is not part of the user interface)

#[cfg(not(windows))]
#[test]
fn command_debug_files_upload_help() {
register_test("debug_files/debug_files-upload-help.trycmd");
Copy link
Member

Choose a reason for hiding this comment

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

windows CI is notoriously slow, esp for I/O operations. We ran into this when trying to run the Node CI in JS on windows: getsentry/sentry-javascript#4616. Maybe we leave a TODO comment on the command as a future performance optimization?

Even opening a GH issue with the list of these disabled tests with help wanted might be nice, maybe somebody else can help figure it out for us!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@kamilogorek kamilogorek merged commit 04c63fe into 2.x Apr 11, 2022
@kamilogorek kamilogorek deleted the more-integration-tests branch April 11, 2022 13:53
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