This repository was archived by the owner on Sep 30, 2024. It is now read-only.
Open
Conversation
bobheadxi
reviewed
May 15, 2024
lib/managedservicesplatform/runtime/contract/mock/contract_mock.go
Outdated
Show resolved
Hide resolved
Comment on lines
17
to
19
| type MockError struct { | ||
| error | ||
| } |
Contributor
Author
There was a problem hiding this comment.
It's so that you can distinguish between between the mock failing because contract.ParseEnv failed and the error returned by env.Validate()
Member
There was a problem hiding this comment.
I suggest against this - callers should be able to not differentiate between mock errors vs not, unless they DIY it (provide a sentinel error to return)
lib/managedservicesplatform/runtime/contract/mock/contract_mock.go
Outdated
Show resolved
Hide resolved
bobheadxi
reviewed
May 20, 2024
| t.Helper() | ||
| e, err := contract.ParseEnv(env) | ||
| if err != nil { | ||
| return nil, MockError{err} |
Member
There was a problem hiding this comment.
A naked error/simply wrapped error is sufficient IMO:
Suggested change
| return nil, MockError{err} | |
| return nil, errors.New(err, "contract.ParseEnv") |
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
I needed to provide a dummy contract and saw that MSP already had this available but it was private.
This PR makes it public while trying to retain it's original intent.
Test plan
bazel test //lib/managedservicesplatform/runtime/...