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

adding paging to get repositories from the database #1793

Closed
wants to merge 6 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
removing underscore prefix
  • Loading branch information
thiago committed Sep 15, 2016
commit 670f37e1626cee7385af85860454222424e76313
20 changes: 10 additions & 10 deletions store/datastore/repos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ func TestRepos(t *testing.T) {
})

g.It("Should Get a Repo List Paginated", func() {
_repos := []*model.RepoLite{
repoLiteList := []*model.RepoLite{
{FullName: "bradrydzewski/drone"},

Choose a reason for hiding this comment

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

the newer versions of the Go linter will complain when underscores are used in variable names, so we've tried to start removing these from our code. So perhaps repoLiteList instead?

{FullName: "drone/drone"},
}
_repo := []*model.Repo{
repoList := []*model.Repo{
{
UserID: 1,
Owner: "bradrydzewski",
Expand All @@ -158,12 +158,12 @@ func TestRepos(t *testing.T) {
FullName: "drone/drone",
},
}
s.CreateRepo(_repo[0])
s.CreateRepo(_repo[1])
s.CreateRepo(repoList[0])
s.CreateRepo(repoList[1])

for i := 0; i < 3000; i++ {
// find by 3000 repos
_repos = append(_repos, &model.RepoLite{FullName: "octocat/hello-world" + fmt.Sprint(i)})
repoLiteList = append(repoLiteList, &model.RepoLite{FullName: "octocat/hello-world" + fmt.Sprint(i)})
// but create only 2000 repos
if i >= 1999 && i < 2999 {
continue
Expand All @@ -174,15 +174,15 @@ func TestRepos(t *testing.T) {
Name: "hello-world" + fmt.Sprint(i),
FullName: "octocat/hello-world" + fmt.Sprint(i),
}
_repo = append(_repo, repo)
repoList = append(repoList, repo)
s.CreateRepo(repo)
}
repos, err := s.GetRepoListOf(_repos)
repos, err := s.GetRepoListOf(repoLiteList)
g.Assert(err == nil).IsTrue()
g.Assert(len(repos)).Equal(2002)
g.Assert(repos[0].ID).Equal(_repo[0].ID)
g.Assert(repos[1].ID).Equal(_repo[1].ID)
g.Assert(repos[2001].ID).Equal(_repo[2001].ID)
g.Assert(repos[0].ID).Equal(repoList[0].ID)
g.Assert(repos[1].ID).Equal(repoList[1].ID)
g.Assert(repos[2001].ID).Equal(repoList[2001].ID)
})

g.It("Should Delete a Repo", func() {
Expand Down