mirror of
https://github.com/go-gitea/gitea.git
synced 2026-04-05 12:05:18 +02:00
Address review: guard trimUnclosedCodeBlock and add GetIssueContentBody test
Only call trimUnclosedCodeBlock when truncation actually occurred, and add unit tests for GetIssueContentBody covering pipe-delimited content. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
a56cc4da86
commit
95522358b1
@ -125,6 +125,24 @@ func TestConsistencyUpdateAction(t *testing.T) {
|
||||
unittest.CheckConsistencyFor(t, &activities_model.Action{})
|
||||
}
|
||||
|
||||
func TestGetIssueContentBody(t *testing.T) {
|
||||
tests := []struct {
|
||||
content string
|
||||
expected string
|
||||
}{
|
||||
{content: "1|simple body", expected: "simple body"},
|
||||
{content: "1|A -->|text| B", expected: "A -->|text| B"},
|
||||
{content: "1|first|second|third", expected: "first|second|third"},
|
||||
{content: "1|", expected: ""},
|
||||
{content: "no-delimiter", expected: ""},
|
||||
{content: "", expected: ""},
|
||||
}
|
||||
for _, test := range tests {
|
||||
action := &activities_model.Action{Content: test.content}
|
||||
assert.Equal(t, test.expected, action.GetIssueContentBody(), "content: %q", test.content)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDeleteIssueActions(t *testing.T) {
|
||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||
|
||||
|
||||
@ -152,7 +152,9 @@ func (a *actionNotifier) CreateIssueComment(ctx context.Context, doer *user_mode
|
||||
truncatedContent = truncatedContent[:lastSpaceIdx] + "…"
|
||||
}
|
||||
}
|
||||
truncatedContent = trimUnclosedCodeBlock(truncatedContent)
|
||||
if truncatedRight != "" {
|
||||
truncatedContent = trimUnclosedCodeBlock(truncatedContent)
|
||||
}
|
||||
act.Content = fmt.Sprintf("%d|%s", issue.Index, truncatedContent)
|
||||
|
||||
if issue.IsPull {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user