mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-14 14:06:15 +01:00
9d943bf374
* Add missing `X-Total-Count` and fix some related bugs
Adds `X-Total-Count` header to APIs that return a list but doesn't have it yet.
Fixed bugs:
* not returned after reporting error (39eb82446c/routers/api/v1/user/star.go (L70)
)
* crash with index out of bounds, API issue/issueSubscriptions
I also found various endpoints that return lists but do not apply/support pagination yet:
```
/repos/{owner}/{repo}/issues/{index}/labels
/repos/{owner}/{repo}/issues/comments/{id}/reactions
/repos/{owner}/{repo}/branch_protections
/repos/{owner}/{repo}/contents
/repos/{owner}/{repo}/hooks/git
/repos/{owner}/{repo}/issue_templates
/repos/{owner}/{repo}/releases/{id}/assets
/repos/{owner}/{repo}/reviewers
/repos/{owner}/{repo}/teams
/user/emails
/users/{username}/heatmap
```
If this is not expected, an new issue should be opened.
Closes #13043
* fmt
* Update routers/api/v1/repo/issue_subscription.go
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Use FindAndCount
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: 6543 <6543@obermui.de>
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
// Copyright 2020 The Gitea Authors. All rights reserved.
|
|
// Use of this source code is governed by a MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package stats
|
|
|
|
import (
|
|
"path/filepath"
|
|
"testing"
|
|
"time"
|
|
|
|
repo_model "code.gitea.io/gitea/models/repo"
|
|
"code.gitea.io/gitea/models/unittest"
|
|
"code.gitea.io/gitea/modules/setting"
|
|
|
|
_ "code.gitea.io/gitea/models"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"gopkg.in/ini.v1"
|
|
)
|
|
|
|
func TestMain(m *testing.M) {
|
|
unittest.MainTest(m, filepath.Join("..", "..", ".."))
|
|
}
|
|
|
|
func TestRepoStatsIndex(t *testing.T) {
|
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
|
setting.Cfg = ini.Empty()
|
|
|
|
setting.NewQueueService()
|
|
|
|
err := Init()
|
|
assert.NoError(t, err)
|
|
|
|
time.Sleep(5 * time.Second)
|
|
|
|
repo, err := repo_model.GetRepositoryByID(1)
|
|
assert.NoError(t, err)
|
|
status, err := repo_model.GetIndexerStatus(repo, repo_model.RepoIndexerTypeStats)
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, "65f1bf27bc3bf70f64657658635e66094edbcb4d", status.CommitSha)
|
|
langs, err := repo_model.GetTopLanguageStats(repo, 5)
|
|
assert.NoError(t, err)
|
|
assert.Empty(t, langs)
|
|
}
|