Rename the main module to gotea.dev and the binary to gotea, and update the application name and English locale. Keep the external gitea.dev/sdk and gitea.dev/actionslib module imports unchanged. Assisted-by: OpenCode:DeepSeek-V4.1-Flash
35 lines
1.5 KiB
Go
35 lines
1.5 KiB
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package issue
|
|
|
|
import (
|
|
"testing"
|
|
|
|
issues_model "gotea.dev/models/issues"
|
|
perm_model "gotea.dev/models/perm"
|
|
access_model "gotea.dev/models/perm/access"
|
|
repo_model "gotea.dev/models/repo"
|
|
"gotea.dev/models/unit"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestFilterReadableCommentsChecksUnitOfSameRepoTargets(t *testing.T) {
|
|
var perm access_model.Permission
|
|
perm.SetUnitsWithDefaultAccessMode([]*repo_model.RepoUnit{{Type: unit.TypeIssues}}, perm_model.AccessModeRead)
|
|
issueRef := &issues_model.Comment{Type: issues_model.CommentTypeIssueRef, RefRepoID: 1}
|
|
pullRef := &issues_model.Comment{Type: issues_model.CommentTypePullRef, RefRepoID: 1, RefIsPull: true}
|
|
issueDependency := &issues_model.Comment{Type: issues_model.CommentTypeAddDependency, DependentIssue: &issues_model.Issue{RepoID: 1}}
|
|
pullDependency := &issues_model.Comment{Type: issues_model.CommentTypeAddDependency, DependentIssue: &issues_model.Issue{RepoID: 1, IsPull: true}}
|
|
repo := &repo_model.Repository{ID: 1}
|
|
|
|
comments, err := FilterReadableComments(t.Context(), nil, perm, &issues_model.Issue{RepoID: 1, Repo: repo}, issues_model.CommentList{issueRef, pullRef, issueDependency, pullDependency})
|
|
require.NoError(t, err)
|
|
assert.Equal(t, issues_model.CommentList{issueRef, issueDependency}, comments)
|
|
assert.Same(t, repo, issueRef.RefRepo)
|
|
assert.Same(t, repo, issueDependency.RefRepo)
|
|
assert.Same(t, repo, issueDependency.DependentIssue.Repo)
|
|
}
|