mirror of
https://github.com/argoproj/argo-cd
synced 2026-04-21 17:07:16 +00:00
chore: remove unused Trunc function (#23232)
Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
This commit is contained in:
parent
ea97dec642
commit
2c3a452fd7
2 changed files with 0 additions and 42 deletions
|
|
@ -1,13 +0,0 @@
|
|||
package text
|
||||
|
||||
import (
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
// truncates messages to n characters
|
||||
func Trunc(message string, n int) string {
|
||||
if utf8.RuneCountInString(message) > n {
|
||||
return string([]rune(message)[0:n-3]) + "..."
|
||||
}
|
||||
return message
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
package text
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestTrunc(t *testing.T) {
|
||||
type args struct {
|
||||
message string
|
||||
n int
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want string
|
||||
}{
|
||||
{"Empty", args{}, ""},
|
||||
{"5", args{message: "xxxxx", n: 5}, "xxxxx"},
|
||||
{"4", args{message: "xxxxx", n: 4}, "x..."},
|
||||
{"Multibyte", args{message: "こんにちは, world", n: 8}, "こんにちは..."},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
assert.Equal(t, tt.want, Trunc(tt.args.message, tt.args.n), "Trunc()")
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue