|
| 1 | +// Copyright 2025 The Gitea Authors. All rights reserved. |
| 2 | +// SPDX-License-Identifier: MIT |
| 3 | + |
| 4 | +package v1_25 |
| 5 | + |
| 6 | +import ( |
| 7 | + "testing" |
| 8 | + |
| 9 | + "code.gitea.io/gitea/models/migrations/base" |
| 10 | + "code.gitea.io/gitea/modules/references" |
| 11 | + "code.gitea.io/gitea/modules/timeutil" |
| 12 | + |
| 13 | + "github.com/stretchr/testify/assert" |
| 14 | +) |
| 15 | + |
| 16 | +func Test_AddCombinedIndexToIssueUser(t *testing.T) { |
| 17 | + type Comment struct { // old struct |
| 18 | + ID int64 `xorm:"pk autoincr"` |
| 19 | + Type int `xorm:"INDEX"` |
| 20 | + PosterID int64 `xorm:"INDEX"` |
| 21 | + OriginalAuthor string |
| 22 | + OriginalAuthorID int64 |
| 23 | + IssueID int64 `xorm:"INDEX"` |
| 24 | + LabelID int64 |
| 25 | + OldProjectID int64 |
| 26 | + ProjectID int64 |
| 27 | + OldMilestoneID int64 |
| 28 | + MilestoneID int64 |
| 29 | + TimeID int64 |
| 30 | + AssigneeID int64 |
| 31 | + RemovedAssignee bool |
| 32 | + AssigneeTeamID int64 `xorm:"NOT NULL DEFAULT 0"` |
| 33 | + ResolveDoerID int64 |
| 34 | + OldTitle string |
| 35 | + NewTitle string |
| 36 | + OldRef string |
| 37 | + NewRef string |
| 38 | + DependentIssueID int64 `xorm:"index"` // This is used by issue_service.deleteIssue |
| 39 | + |
| 40 | + CommitID int64 |
| 41 | + Line int64 // - previous line / + proposed line |
| 42 | + TreePath string |
| 43 | + Content string `xorm:"LONGTEXT"` |
| 44 | + ContentVersion int `xorm:"NOT NULL DEFAULT 0"` |
| 45 | + |
| 46 | + // Path represents the 4 lines of code cemented by this comment |
| 47 | + Patch string `xorm:"-"` |
| 48 | + PatchQuoted string `xorm:"LONGTEXT patch"` |
| 49 | + |
| 50 | + CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` |
| 51 | + UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` |
| 52 | + |
| 53 | + // Reference issue in commit message |
| 54 | + CommitSHA string `xorm:"VARCHAR(64)"` |
| 55 | + |
| 56 | + ReviewID int64 `xorm:"index"` |
| 57 | + Invalidated bool |
| 58 | + |
| 59 | + // Reference an issue or pull from another comment, issue or PR |
| 60 | + // All information is about the origin of the reference |
| 61 | + RefRepoID int64 `xorm:"index"` // Repo where the referencing |
| 62 | + RefIssueID int64 `xorm:"index"` |
| 63 | + RefCommentID int64 `xorm:"index"` // 0 if origin is Issue title or content (or PR's) |
| 64 | + RefAction references.XRefAction `xorm:"SMALLINT"` // What happens if RefIssueID resolves |
| 65 | + RefIsPull bool |
| 66 | + |
| 67 | + CommentMetaData string `xorm:"JSON TEXT"` // put all non-index metadata in a single field |
| 68 | + } |
| 69 | + |
| 70 | + // Prepare and load the testing database |
| 71 | + x, deferable := base.PrepareTestEnv(t, 0, new(Comment)) |
| 72 | + defer deferable() |
| 73 | + |
| 74 | + assert.NoError(t, AddBeforeCommitIDForComment(x)) |
| 75 | +} |
0 commit comments