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

[PFS-207] Add GetWithID Functions to Projects and Repos #9782

Merged
merged 5 commits into from Feb 29, 2024

Conversation

FahadBSyed
Copy link
Contributor

The goal of this PR is to add GetXWithID functions to Projects and Repos so they can be consumed by PFS APIs.

@FahadBSyed FahadBSyed requested a review from a team as a code owner February 28, 2024 19:35
@@ -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{})
Copy link
Contributor

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.

Copy link
Contributor Author

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
	}))

Copy link
Contributor

@brendoncarroll brendoncarroll left a 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.

@FahadBSyed FahadBSyed merged commit 1d078e8 into master Feb 29, 2024
19 of 20 checks passed
@FahadBSyed FahadBSyed deleted the PFS-207-pfsdb branch February 29, 2024 18:16
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.

None yet

2 participants