Skip to content

[Feature] Add unit test for update service request validation #3546

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

LeoLiao123
Copy link
Contributor

@LeoLiao123 LeoLiao123 commented May 5, 2025

Why are these changes needed?

See #3539

Related issue number

Closes #3539

Manual test

image

Checks

  • I've made sure the tests are passing.
  • Testing Strategy
    • Unit tests
    • Manual tests
    • This PR is not tested :(

Signed-off-by: LeoLiao123 <leoyeepaa@gmail.com>
@LeoLiao123 LeoLiao123 marked this pull request as ready for review May 5, 2025 16:03
Signed-off-by: LeoLiao123 <leoyeepaa@gmail.com>
@LeoLiao123
Copy link
Contributor Author

@dentiny PTAL

@@ -171,7 +171,7 @@ func ValidateCreateServiceRequest(request *api.CreateRayServiceRequest) error {

func ValidateUpdateServiceRequest(request *api.UpdateRayServiceRequest) error {
if request.Name == "" {
return util.NewInvalidInputError("Service name is empty. Please specify a valid value.")
return util.NewInvalidInputError("Name is empty. Please specify a valid value.")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The original message is identical to the one on line 189 and may cause confusion when debugging.

@@ -190,7 +190,7 @@ func ValidateUpdateServiceRequest(request *api.UpdateRayServiceRequest) error {
}

if request.Service.User == "" {
return util.NewInvalidInputError("User who create the Service is empty. Please specify a valid value.")
return util.NewInvalidInputError("User who update the Service is empty. Please specify a valid value.")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

To avoid confusion with ValidateCreateServiceRequest, I changed the message to refer to an 'update' instead.

Copy link
Contributor

@dentiny dentiny left a comment

Choose a reason for hiding this comment

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

Sorry for the latency! I'm kinda busy these days, feel free to ping me on slack directly. Thank you!

LeoLiao123 added 3 commits May 8, 2025 23:52
…ones.

Signed-off-by: LeoLiao123 <leoyeepaa@gmail.com>
Signed-off-by: LeoLiao123 <leoyeepaa@gmail.com>
Signed-off-by: LeoLiao123 <leoyeepaa@gmail.com>
@LeoLiao123
Copy link
Contributor Author

Hi @dentiny, I've re-triggered the CI and it has passed. Please take a look. Thanks!

@LeoLiao123 LeoLiao123 requested a review from dentiny May 11, 2025 07:06
Signed-off-by: LeoLiao123 <leoyeepaa@gmail.com>
}
// Execute tests sequentially
for _, tc := range tests {
tc := tc // capture range variable
Copy link
Contributor

Choose a reason for hiding this comment

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

curious why capture?

Copy link
Contributor Author

@LeoLiao123 LeoLiao123 May 11, 2025

Choose a reason for hiding this comment

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

@dentiny I initially followed the previous test pattern, but after experimenting I found that capturing isn’t necessary to iterate all test cases, so I’ve removed it in my latest commit!

exp screenshot :
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As a side note, I was curious and looked into why this pattern existed. I found that before Go 1.22 it was indeed necessary to recapture the range variable this way, but it has since been fixed. Reference

Copy link
Contributor

Choose a reason for hiding this comment

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

gotcha, I think it's capture by ref vs capture by value

Signed-off-by: LeoLiao123 <leoyeepaa@gmail.com>
Copy link
Contributor

@dentiny dentiny left a comment

Choose a reason for hiding this comment

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

Thanks!

@dentiny
Copy link
Contributor

dentiny commented May 11, 2025

just fyi, I usually re-request review after address all comments:

  • it's an indicator you've addressed comments
  • I sometimes check my github review queue

feel free to ping me directly (on slack), and sorry for the latency

@LeoLiao123
Copy link
Contributor Author

Got it! Thanks for your thorough explanation and the review!

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.

[Feature] Add unit test for update service request validation
3 participants