-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathattachments_test.go
More file actions
28 lines (25 loc) · 910 Bytes
/
Copy pathattachments_test.go
File metadata and controls
28 lines (25 loc) · 910 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package main
import (
"strings"
"testing"
)
func TestSummarizeAttachmentLogContent_NoTruncation(t *testing.T) {
got := summarizeAttachmentLogContent([]string{"alpha", "beta"})
want := "alpha\n\nbeta"
if got != want {
t.Fatalf("unexpected summary: got %q want %q", got, want)
}
}
func TestSummarizeAttachmentLogContent_TruncatesAndMarks(t *testing.T) {
input := strings.Repeat("x", attachmentLogMaxChars+50)
got := summarizeAttachmentLogContent([]string{input})
if !strings.Contains(got, "...[truncated in log; full attachment text stored in DB]") {
t.Fatalf("expected truncation marker in %q", got)
}
if len(got) <= attachmentLogMaxChars {
t.Fatalf("expected output longer than cap due to suffix, got len=%d cap=%d", len(got), attachmentLogMaxChars)
}
if !strings.HasPrefix(got, strings.Repeat("x", attachmentLogMaxChars)) {
t.Fatalf("expected output to start with capped prefix")
}
}