From 8e900c9eb5f55c7c3aa0c39f4da11bd9bb86c7aa Mon Sep 17 00:00:00 2001 From: Daniel Szoke Date: Fri, 15 Nov 2024 14:19:04 +0100 Subject: [PATCH] ref(test): Use `TestManager` in new chunk upload test Use the `TestManager` in the recently-added `ensure_correct_assemble_call` test. In the future, we would plan to add `assert_cmd` support to `TestManager`, which would make the remaining custom logic in this test redundant, but we will wait until we have a better idea of how this should look like. For now, this change should make #2223 easier to implement --- tests/integration/debug_files/upload.rs | 31 ++++++++++++++----------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/tests/integration/debug_files/upload.rs b/tests/integration/debug_files/upload.rs index 21664d47dc..e4ce0b0cd7 100644 --- a/tests/integration/debug_files/upload.rs +++ b/tests/integration/debug_files/upload.rs @@ -155,22 +155,27 @@ fn command_debug_files_upload_no_upload() { /// The mock assemble endpoint returns a 200 response simulating the case where all chunks /// are already uploaded. fn ensure_correct_assemble_call() { - let _manager = TestManager::new().mock_endpoint( - MockEndpointBuilder::new("GET", "/api/0/organizations/wat-org/chunk-upload/", 200) - .with_response_file("debug_files/get-chunk-upload.json"), - ); - - let assemble = mockito::mock("POST", "/api/0/projects/wat-org/wat-project/files/difs/assemble/") - .match_body(r#"{"21b76b717dbbd8c89e42d92b29667ac87aa3c124":{"name":"SrcGenSampleApp.pdb","debug_id":"c02651ae-cd6f-492d-bc33-0b83111e7106-8d8e7c60","chunks":["21b76b717dbbd8c89e42d92b29667ac87aa3c124"]}}"#) - .with_status(200) - .with_header("content-type", "application/json") - .with_body(r#"{ + let manager = TestManager::new() + .mock_endpoint( + MockEndpointBuilder::new("GET", "/api/0/organizations/wat-org/chunk-upload/", 200) + .with_response_file("debug_files/get-chunk-upload.json"), + ) + .mock_endpoint( + MockEndpointBuilder::new( + "POST", + "/api/0/projects/wat-org/wat-project/files/difs/assemble/", + 200, + ) + .with_header_matcher("content-type", "application/json".into()) + .with_response_body( + r#"{ "21b76b717dbbd8c89e42d92b29667ac87aa3c124": { "state": "ok", "missingChunks": [] } - }"#) - .create(); + }"#, + ), + ); let mut command = Command::cargo_bin("sentry-cli").expect("sentry-cli should be available"); @@ -193,6 +198,6 @@ fn ensure_correct_assemble_call() { // First assert the mock was called as expected, then that the command was successful. // This is because failure with the mock assertion can cause the command to fail, and // the mock assertion failure is likely more interesting in this case. - assemble.assert(); + manager.assert_mock_endpoints(); command_result.success(); }