mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-10 05:24:18 +09:00
Adds REST APIs for project boards for repo, org and user scopes, using as much shared code as possible for all 3 scopes. Fixes: https://github.com/go-gitea/gitea/issues/14299 Fixes: https://github.com/go-gitea/gitea/issues/31769 Fixes: https://github.com/go-gitea/gitea/issues/35921 Replaces: https://github.com/go-gitea/gitea/pull/37518 Replaces: https://github.com/go-gitea/gitea/pull/36008 Replaces: https://github.com/go-gitea/gitea/pull/28111 Replaces: https://github.com/go-gitea/gitea/pull/31768 Signed-off-by: silverwind <me@silverwind.io> Co-authored-by: Supen.Huang <supen.huang@qq.com> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Ember <ember@mubergacres.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: beardev-in <abhinav.edulakanti@gmail.com>
41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package project
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gitea.dev/models/db"
|
|
"gitea.dev/models/unittest"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestGetColumnsPaginated(t *testing.T) {
|
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
|
|
|
const projectID = 1
|
|
count, err := CountColumns(t.Context(), projectID)
|
|
assert.NoError(t, err)
|
|
assert.EqualValues(t, 3, count)
|
|
|
|
// Page 1, limit 2 — returns first 2 columns
|
|
page1, err := GetColumns(t.Context(), projectID, db.ListOptions{Page: 1, PageSize: 2})
|
|
assert.NoError(t, err)
|
|
assert.Len(t, page1, 2)
|
|
|
|
// Page 2, limit 2 — returns remaining column
|
|
page2, err := GetColumns(t.Context(), projectID, db.ListOptions{Page: 2, PageSize: 2})
|
|
assert.NoError(t, err)
|
|
assert.Len(t, page2, 1)
|
|
|
|
// Page 1 and page 2 together cover all columns with no overlap
|
|
allIDs := make(map[int64]bool)
|
|
for _, c := range append(page1, page2...) {
|
|
assert.False(t, allIDs[c.ID], "duplicate column ID %d across pages", c.ID)
|
|
allIDs[c.ID] = true
|
|
}
|
|
assert.Len(t, allIDs, 3)
|
|
}
|