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

[vms/avm] Replace strings.Replace with fmt.Sprintf in tests #3177

Merged
merged 3 commits into from
Jul 12, 2024

Conversation

dhrubabasu
Copy link
Contributor

Why this should be merged

@ARR4N pointed out that we could use fmt.Sprintf with explicit arg indices for better readability during review of another PR (#3165 (comment))

How this works

Replaces strings.Replace with fmt.Sprintf in the avm tests (only place we do this pattern currently)

How this was tested

CI

@dhrubabasu dhrubabasu added testing This primarily focuses on testing cleanup Code quality improvement labels Jul 6, 2024
@dhrubabasu dhrubabasu added this to the v1.11.10 milestone Jul 6, 2024
@dhrubabasu dhrubabasu self-assigned this Jul 6, 2024
Copy link
Contributor

@ARR4N ARR4N left a comment

Choose a reason for hiding this comment

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

Approving with a requested change that doesn't need re-review.

vms/avm/service_test.go Outdated Show resolved Hide resolved
vms/avm/service_test.go Outdated Show resolved Hide resolved
@tsachiherman
Copy link
Contributor

I think it's much better with these changes; next step, I'd suggest moving these large json structure into an external file and embed these doing buildtime. ( I wouldn't make this suggestion for few lines of json.. but these jsons are quite massive, and look like they might be changing regardless of the testing code ).

@marun
Copy link
Contributor

marun commented Jul 9, 2024

Assuming use of json.Marshal/Unmarshal in the code under test, would it make sense to switch to composing JSON test data in the same manner rather than via string interpolation?

@dhrubabasu
Copy link
Contributor Author

I think it's much better with these changes; next step, I'd suggest moving these large json structure into an external file and embed these doing buildtime. ( I wouldn't make this suggestion for few lines of json.. but these jsons are quite massive, and look like they might be changing regardless of the testing code ).

These won't be changing at all. The reason the JSON is in the test code is to guarantee we don't make a change that accidentally changes a JSON serialization (which would impact downstream consumers, particularly in javascript land)

@dhrubabasu
Copy link
Contributor Author

Assuming use of json.Marshal/Unmarshal in the code under test, would it make sense to switch to composing JSON test data in the same manner rather than via string interpolation?

I like the idea of keeping the JSON itself since Marshal versus Unmarshal could lead to an undesired change (serializing null instead of [] for example)

@StephenButtolph StephenButtolph added this pull request to the merge queue Jul 12, 2024
Merged via the queue into master with commit 57fe51d Jul 12, 2024
20 checks passed
@StephenButtolph StephenButtolph deleted the remove-strings-replace-in-tests branch July 12, 2024 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Code quality improvement testing This primarily focuses on testing
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants