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

fix: wrong pages number which includes private repository count. #844

Merged
merged 1 commit into from
Feb 6, 2017

Conversation

appleboy
Copy link
Member

@appleboy appleboy commented Feb 5, 2017

fix #843

  • Add unit testing.
  • Add GetPublicRepositoryCount func
  • Add GetPrivateRepositoryCount func

@lunny
Copy link
Member

lunny commented Feb 5, 2017

trusted LGTM

@tboerger tboerger added the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label Feb 5, 2017
@lunny lunny added this to the 1.1.0 milestone Feb 5, 2017
@lunny lunny added the type/bug label Feb 5, 2017
models/repo.go Outdated
return getPublicRepositoryCount(x, u)
}

// GetPrivateRepositoryCount returns the total number of public repositories of user.
Copy link
Member

Choose a reason for hiding this comment

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

public -> private

Copy link
Member Author

Choose a reason for hiding this comment

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

Why? Already has getPrivateRepositoryCount private function.

Copy link
Member

Choose a reason for hiding this comment

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

returns the total number of public repositories of user. -> returns the total number of private repositories of user. 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

@ethantkoenig understood. 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

func TestGetRepositoryCount(t *testing.T) {
assert.NoError(t, PrepareTestDatabase())

count, _ := GetRepositoryCount(&User{ID: int64(10)})
Copy link
Member

Choose a reason for hiding this comment

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

Could we assert that the returned error is nil, instead of just ignoring it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

func TestGetPublicRepositoryCount(t *testing.T) {
assert.NoError(t, PrepareTestDatabase())

count, _ := GetPublicRepositoryCount(&User{ID: int64(10)})
Copy link
Member

Choose a reason for hiding this comment

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

^

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

func TestGetPrivateRepositoryCount(t *testing.T) {
assert.NoError(t, PrepareTestDatabase())

count, _ := GetPrivateRepositoryCount(&User{ID: int64(10)})
Copy link
Member

Choose a reason for hiding this comment

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

^

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

if showPrivate {
total = ctxUser.NumRepos
} else {
count, _ := models.GetPublicRepositoryCount(ctxUser)
Copy link
Member

Choose a reason for hiding this comment

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

Could we check if the returned error is nil instead of ignoring it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

@ethantkoenig ethantkoenig left a comment

Choose a reason for hiding this comment

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

LGTM

@ethantkoenig
Copy link
Member

LGTM

@tboerger tboerger added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Feb 6, 2017
@lunny lunny merged commit 71d35da into go-gitea:master Feb 6, 2017
@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong pages number which include private repository count
4 participants