mirror of
https://github.com/hanzoai/forge.git
synced 2026-10-30 15:00:39 +00:00
2978 files. The fork is 2026-07-15 (rebrand: gitea.dev -> github.com/hanzoai/git), so 2026 is the year, and "Copyright 2026 Hanzo AI, Inc." was already the form used by the handful of files that had ours. Shape is now: // Copyright 2026 Hanzo AI, Inc. All rights reserved. // Copyright 2015 The Gogs Authors. All rights reserved. // Copyright 2019 The Gitea Authors. All rights reserved. // SPDX-License-Identifier: MIT Ours on top, theirs retained verbatim. Retained because MIT requires it, and separately because they are true — those authors did write that code. Not renamed to "The Git Authors": Git is a different project under a different license, and putting its name here would attribute this code to people who have nothing to do with it. Adding our line is the fix; overwriting theirs would have been both a licence violation and a false statement. gofmt still reports import-order drift in some of these files. It predates this change (verified against a stash) and is left alone rather than burying a one-line-per-file legal change under 3000 files of unrelated reordering. Build clean. Co-authored-by: Hanzo Dev <[email protected]>
93 lines
3.0 KiB
Go
93 lines
3.0 KiB
Go
// Copyright 2026 Hanzo AI, Inc. All rights reserved.
|
|
// Copyright 2017 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package issues_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
issues_model "github.com/hanzoai/git/models/issues"
|
|
"github.com/hanzoai/git/models/unittest"
|
|
"github.com/hanzoai/git/modules/setting"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestIssueList_LoadRepositories(t *testing.T) {
|
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
|
|
|
issueList := issues_model.IssueList{
|
|
unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 1}),
|
|
unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 2}),
|
|
unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 4}),
|
|
}
|
|
|
|
repos, err := issueList.LoadRepositories(t.Context())
|
|
assert.NoError(t, err)
|
|
assert.Len(t, repos, 2)
|
|
for _, issue := range issueList {
|
|
assert.Equal(t, issue.RepoID, issue.Repo.ID)
|
|
}
|
|
}
|
|
|
|
func TestIssueList_LoadIsRead(t *testing.T) {
|
|
// Regression: In("issue_id") was missing the issueIDs argument, causing
|
|
// xorm to generate "0=1" and never mark any issue as read.
|
|
require.NoError(t, unittest.PrepareTestDatabase())
|
|
|
|
issue1 := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 1})
|
|
issue2 := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 2})
|
|
|
|
// Fixture: uid=1 has is_read=true on issue 1 only.
|
|
issueList := issues_model.IssueList{issue1, issue2}
|
|
require.NoError(t, issueList.LoadIsRead(t.Context(), 1))
|
|
|
|
assert.True(t, issue1.IsRead, "issue 1 should be marked read for user 1")
|
|
assert.False(t, issue2.IsRead, "issue 2 should not be marked read for user 1")
|
|
}
|
|
|
|
func TestIssueList_LoadAttributes(t *testing.T) {
|
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
|
setting.Service.EnableTimetracking = true
|
|
issueList := issues_model.IssueList{
|
|
unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 1}),
|
|
unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 4}),
|
|
}
|
|
|
|
assert.NoError(t, issueList.LoadAttributes(t.Context()))
|
|
for _, issue := range issueList {
|
|
assert.Equal(t, issue.RepoID, issue.Repo.ID)
|
|
for _, label := range issue.Labels {
|
|
assert.Equal(t, issue.RepoID, label.RepoID)
|
|
unittest.AssertExistsAndLoadBean(t, &issues_model.IssueLabel{IssueID: issue.ID, LabelID: label.ID})
|
|
}
|
|
if issue.PosterID > 0 {
|
|
assert.Equal(t, issue.PosterID, issue.Poster.ID)
|
|
}
|
|
if issue.AssigneeID > 0 {
|
|
assert.Equal(t, issue.AssigneeID, issue.Assignee.ID)
|
|
}
|
|
if issue.MilestoneID > 0 {
|
|
assert.Equal(t, issue.MilestoneID, issue.Milestone.ID)
|
|
}
|
|
if issue.IsPull {
|
|
assert.Equal(t, issue.ID, issue.PullRequest.IssueID)
|
|
}
|
|
for _, attachment := range issue.Attachments {
|
|
assert.Equal(t, issue.ID, attachment.IssueID)
|
|
}
|
|
for _, comment := range issue.Comments {
|
|
assert.Equal(t, issue.ID, comment.IssueID)
|
|
}
|
|
if issue.ID == int64(1) {
|
|
assert.Equal(t, int64(400), issue.TotalTrackedTime)
|
|
assert.NotEmpty(t, issue.Projects)
|
|
assert.Equal(t, int64(1), issue.Projects[0].ID)
|
|
} else {
|
|
assert.Empty(t, issue.Projects)
|
|
}
|
|
}
|
|
}
|