From 55577201a4f93c537d0a3f0f893e213b09609813 Mon Sep 17 00:00:00 2001 From: Niko Storni Date: Wed, 17 Mar 2021 16:40:37 +0100 Subject: [PATCH] remove livelock --- namer/names.go | 2 +- namer/names_test.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/namer/names.go b/namer/names.go index 40bf620..413cd9f 100644 --- a/namer/names.go +++ b/namer/names.go @@ -72,7 +72,7 @@ func getClaimNameFromTitle(title string, attempt int) string { name := chunks[0] if len(name) > maxLen { - return truncateUnicode(name, maxLen) + return truncateUnicode(name, maxLen) + suffix } for _, chunk := range chunks[1:] { diff --git a/namer/names_test.go b/namer/names_test.go index 02c688d..d02f8e7 100644 --- a/namer/names_test.go +++ b/namer/names_test.go @@ -21,4 +21,6 @@ func Test_getClaimNameFromTitle(t *testing.T) { assert.Equal(t, "test", name) name = getClaimNameFromTitle("『あなたはただの空の殻でした』", 0) assert.Equal(t, "『あなたはただの空の殻でした』", name) + name = getClaimNameFromTitle("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 50) + assert.Equal(t, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-50", name) }