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

Refactor MultiLineAssertions to use SingleLineAssertions internally #84

Merged
merged 6 commits into from
Dec 30, 2024

Conversation

ryan-gang
Copy link
Collaborator

@ryan-gang ryan-gang commented Dec 27, 2024

This pull request includes significant refactoring and enhancements to the multi-line assertion functionality within the codebase. The changes mainly focus on replacing the old method of handling multi-line assertions with a more structured and flexible approach. Additionally, some minor improvements and cleanups are included.

Refactoring and Enhancements:

  • internal/assertions/multi_line_assertion.go: Replaced the ExpectedOutput and FallbackPatterns fields with a SingleLineAssertions slice. Added methods to construct and manipulate multi-line assertions, including NewMultiLineAssertion, NewEmptyMultiLineAssertion, AddSingleLineAssertion, and updated Run method to handle the new structure.

  • internal/stage_r1.go: Updated the testR1 function to use the new MultiLineAssertion constructor for multi-line test cases. [1] [2]

  • internal/stage_r3.go: Updated the testR3 function to use the new MultiLineAssertion constructor for multi-line test cases. [1] [2] [3] [4]

  • internal/stage_r4.go: Enhanced the testR4 function to use the new MultiLineAssertion structure, including handling regex patterns for error messages.

Minor Improvements:

  • internal/test_cases/command_reflection_test_case.go and internal/test_cases/command_response_test_case.go: Modified the Run method to use formatted strings for success messages. [1] [2]

  • internal/test_cases/command_with_multiline_response_test_case.go: Updated the CommandWithMultilineResponseTestCase struct to use the new MultiLineAssertion field and modified the Run method accordingly. [1] [2] [3]

- Introduced SingleLineAssertions to allow for more granular assertions.
- Added NewMultiLineAssertion and NewEmptyMultiLineAssertion constructors.
- Implemented AddSingleLineAssertion method for adding single line assertions with fallback patterns.
- Updated Inspect and Run methods to accommodate the new structure.
- Removed ExpectedOutput and FallbackPatterns fields.
- Introduced MultiLineAssertion field to streamline assertion handling.
- Updated Run method to utilize the new MultiLineAssertion structure.
- Replaced ExpectedOutput and FallbackPatterns with MultiLineAssertion in CommandWithMultilineResponseTestCase for stages R1 and R3.
- Enhanced test case structure for improved assertion handling and consistency across tests.
- Updated testR4 function to utilize MultiLineAssertion for error message validation.
- Replaced ExpectedOutput and FallbackPatterns with a more structured approach using AddSingleLineAssertion.
- Improved regex handling for error messages to ensure accurate assertions.
@ryan-gang ryan-gang self-assigned this Dec 27, 2024
Copy link

linear bot commented Dec 27, 2024

@ryan-gang ryan-gang added the enhancement New feature or request label Dec 27, 2024
@ryan-gang ryan-gang merged commit 40ed31c into main Dec 30, 2024
2 checks passed
@ryan-gang ryan-gang deleted the CC-1566 branch December 30, 2024 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant