refactor: extract TruncateRunes function for safe string truncation with suffix

Signed-off-by: Deluan <deluan@navidrome.org>

# Conflicts:
#	core/share.go
#	core/share_test.go
This commit is contained in:
Deluan
2025-11-06 14:26:51 -05:00
parent fe1cee0159
commit 58b5ed86df
4 changed files with 93 additions and 17 deletions
+2 -2
View File
@@ -52,7 +52,7 @@ var _ = Describe("Share", func() {
entity := &model.Share{Description: "test", ResourceIDs: "789"}
_, err := repo.Save(entity)
Expect(err).ToNot(HaveOccurred())
Expect(entity.Contents).To(Equal("Example Media File But The..."))
Expect(entity.Contents).To(Equal("Example Media File But The ..."))
})
It("does not truncate CJK labels shorter than 30 runes", func() {
@@ -68,7 +68,7 @@ var _ = Describe("Share", func() {
entity := &model.Share{Description: "test", ResourceIDs: "789"}
_, err := repo.Save(entity)
Expect(err).ToNot(HaveOccurred())
Expect(entity.Contents).To(Equal("私の中の幻想的世界観及びその顕現を想起させたある現実..."))
Expect(entity.Contents).To(Equal("私の中の幻想的世界観及びその顕現を想起させたある現実..."))
})
})