Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Conversation

@burmudar
Copy link
Contributor

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

@burmudar burmudar requested a review from a team May 15, 2024 08:42
@burmudar burmudar self-assigned this May 15, 2024
@cla-bot cla-bot bot added the cla-signed label May 15, 2024
Copy link
Member

@jac jac left a comment

Choose a reason for hiding this comment

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

Nice QOL improvement 👍

Comment on lines 17 to 19
type MockError struct {
error
}
Copy link
Member

Choose a reason for hiding this comment

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

what is this type for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's so that you can distinguish between between the mock failing because contract.ParseEnv failed and the error returned by env.Validate()

Copy link
Member

Choose a reason for hiding this comment

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

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)

t.Helper()
e, err := contract.ParseEnv(env)
if err != nil {
return nil, MockError{err}
Copy link
Member

Choose a reason for hiding this comment

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

A naked error/simply wrapped error is sufficient IMO:

Suggested change
return nil, MockError{err}
return nil, errors.New(err, "contract.ParseEnv")

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants