-
Notifications
You must be signed in to change notification settings - Fork 15
Replace magic strings with constants in hash_test.go for better maintainability #829
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Co-authored-by: mawasile <50197777+mawasile@users.noreply.github.com>
Copilot finished work on behalf of
mawasile
June 5, 2025 07:01
There was a problem hiding this 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 improves the maintainability of the test function by replacing hardcoded string literals with named constants.
- Replaced magic strings in TestUnitCalculateSHA256 with constants.
- Defined two constants (sameContent and differentContent) at the beginning of the test function.
- Updated the changelog to reflect the improved test structure.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File | Description |
---|---|
internal/helpers/hash_test.go | Replaced magic strings with constants to improve clarity and maintainability. |
.changes/unreleased/improved_test_structure.yaml | Documented the improvement in test structure by replacing magic strings. |
mawasile
reviewed
Jun 5, 2025
Co-authored-by: mawasile <50197777+mawasile@users.noreply.github.com>
Copilot finished work on behalf of
mawasile
June 5, 2025 19:01
mawasile
approved these changes
Jun 9, 2025
mattdot
approved these changes
Jun 12, 2025
eduardodfmex
approved these changes
Jun 13, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
ai assisted
Pull requests that have be fully or partially implemented using Copilot or AI
ai found
Issues and Bugs that were found using AI
copilot
fixed using GitHub copilot autonomous agent
skip-changelog
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The
TestUnitCalculateSHA256
function ininternal/helpers/hash_test.go
was using hardcoded string literals"same"
and"different"
as file content in multiple places. This created a maintainability issue where:Solution
Replaced magic strings with named constants defined at the function level:
Changes made:
TestUnitCalculateSHA256
function[]byte("same")
→[]byte(sameContent)
(2 locations)[]byte("different")
→[]byte(differentContent)
(1 location)Benefits
Testing
TestUnitCalculateSHA256
)This is a small but important improvement that enhances code quality and follows established best practices for test maintainability.
Fixes #826.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
http://168.63.129.16:80/machine/
/usr/bin/python3 -u bin/WALinuxAgent-2.13.1.1-py3.9.egg -collect-logs
(http block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.