mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-27 14:13:52 +03:00
d5c6036c53
- The `OR` should be inside the `AND` condition to not 'bypass' the other conditions. - Added minimal unit test. - Regression from2675a24649
(cherry picked from commit0055fdbdc4
)
30 lines
844 B
Go
30 lines
844 B
Go
// Copyright 2024 The Forgejo Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package activities
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"code.gitea.io/gitea/models/db"
|
|
repo_model "code.gitea.io/gitea/models/repo"
|
|
"code.gitea.io/gitea/models/unittest"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestGetActivityStats(t *testing.T) {
|
|
require.NoError(t, unittest.PrepareTestDatabase())
|
|
|
|
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
|
|
|
|
stats, err := GetActivityStats(db.DefaultContext, repo, time.Unix(0, 0), true, true, true, true)
|
|
require.NoError(t, err)
|
|
|
|
assert.EqualValues(t, 2, stats.ActiveIssueCount())
|
|
assert.EqualValues(t, 2, stats.OpenedIssueCount())
|
|
assert.EqualValues(t, 0, stats.ClosedIssueCount())
|
|
assert.EqualValues(t, 3, stats.ActivePRCount())
|
|
}
|