Skip to content

test: Refactor and tests Sourcemap command#26

Merged
miquelbeltran merged 7 commits intomainfrom
sourcemap-refactor-test
Jun 26, 2025
Merged

test: Refactor and tests Sourcemap command#26
miquelbeltran merged 7 commits intomainfrom
sourcemap-refactor-test

Conversation

@miquelbeltran
Copy link
Contributor

test: Refactor and tests Sourcemap command

Description 📝

  • Purpose: Part of Implement tests #4 to increase the test coverage of the cli
  • Approach: Refactored the Source feature to enable testing. Created two test files with corresponding mocks. Includes generated code.

Type of change

  • Tests

Updates

  • Refactored the Sourcemap command feature to enhance testability and structure.
  • Added sourcemap command and api tests

Test plan 🧪

  • Unit tests and tested upload command

Author to check 👓

  • Project and all contained modules builds successfully
  • Self-/dev-tested
  • Unit/UI/Automation/Integration tests provided where applicable
  • Code is written to standards
  • Appropriate documentation written (code comments, internal docs)

Reviewer to check ✔️

  • Project and all contained modules builds successfully
  • Change has been dev-/reviewer-tested, where possible
  • Unit/UI/Automation/Integration tests provided where applicable
  • Code is written to standards
  • Appropriate documentation written (code comments, internal docs)

@miquelbeltran miquelbeltran requested a review from Copilot June 19, 2025 08:38
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the sourcemap command infrastructure to support dependency injection and return values, replaces manual multipart request construction with a RaygunMultipartRequestBuilder, and adds unit tests (with generated Mockito mocks) for both the sourcemap and symbols features to increase CLI test coverage.

  • Refactored SourcemapCommand, SourcemapBase, and related classes to accept an injected SourcemapApi and return bool instead of calling exit directly.
  • Replaced manual http.MultipartRequest code in SourcemapApi with a builder pattern (RaygunMultipartRequestBuilder) and updated the upload logic.
  • Added comprehensive unit tests under test/sourcemaps and updated/generated mocks; updated symbols mocks to point to the correct test path.

Reviewed Changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/symbols/symbols_command_test.mocks.dart Updated import prefixes and mock class references.
test/symbols/symbols_api_test.mocks.dart Corrected test path in generated mock header.
test/sourcemaps/sourcemap_command_test.mocks.dart Added generated mocks for SourcemapCommand.
test/sourcemaps/sourcemap_command_test.dart New tests for single-file, flutter, node, unsupported, and help cases.
test/sourcemaps/sourcemap_api_test.mocks.dart Added generated mocks for http.Client.
test/sourcemaps/sourcemap_api_test.dart New tests for SourcemapApi.uploadSourcemap success, failure, and missing file cases.
lib/src/symbols/symbols_command.dart Renamed parser method calls from buildParserSymbols to buildParser.
lib/src/sourcemap/sourcemap_single_file.dart Changed upload() return type to Future<bool> and injected api.
lib/src/sourcemap/sourcemap_command.dart Converted to a RaygunCommand subclass with DI and a run method returning bool.
lib/src/sourcemap/sourcemap_base.dart Added api field and changed upload() signature to Future<bool>.
lib/src/sourcemap/sourcemap_api.dart Swapped in RaygunMultipartRequestBuilder, cleaned up multipart logic.
lib/src/sourcemap/node/sourcemap_node.dart Changed upload() to return bool and injected api.
lib/src/sourcemap/flutter/sourcemap_flutter.dart Changed upload() to return bool and injected api.
lib/src/core/raygun_command.dart Simplified abstract interface to only execute and buildParser.

miquelbeltran and others added 2 commits June 19, 2025 10:42
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@TheRealAgentK TheRealAgentK self-requested a review June 20, 2025 09:17
Copy link
Contributor

@TheRealAgentK TheRealAgentK left a comment

Choose a reason for hiding this comment

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

LGTM

@miquelbeltran miquelbeltran merged commit ad95418 into main Jun 26, 2025
5 checks passed
@miquelbeltran miquelbeltran deleted the sourcemap-refactor-test branch June 26, 2025 06:45
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.

3 participants