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
[PFS-207] Add GetWithID Functions to Projects and Repos #9782
Conversation
…can be used in picker api.
@@ -37,8 +37,7 @@ func (err *ProjectNotFoundError) Error() string { | |||
} | |||
|
|||
func (err *ProjectNotFoundError) Is(other error) bool { | |||
_, ok := other.(*ProjectNotFoundError) | |||
return ok | |||
return errors.As(other, &ProjectNotFoundError{}) |
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.
Check if you need the double pointer here.
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.
This is actually only one pointer:
// ProjectNotFoundError is returned by GetProject() when a project is not found in postgres.
type ProjectNotFoundError struct {
Name string
ID ProjectID
}
But to confirm, that this works, we're using it in projects_test.go
...
// validate error for attempting to get non-existent project.
_, err = pfsdb.GetProject(cbCtx, tx, 3)
require.YesError(t, err, "should not be able to get non-existent project")
require.True(t, (&pfsdb.ProjectNotFoundError{ID: 3}).Is(err))
return nil
}))
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.
A few things. Otherwise LGTM.
errors.As
is tricky. I would exercise that code path in a test.
The goal of this PR is to add
GetXWithID
functions to Projects and Repos so they can be consumed by PFS APIs.