refactor(bodylimit): 将 FormatSize 改为私有函数 formatSize
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
941c44b798
commit
5e86f47650
@ -279,7 +279,7 @@ func ParseSize(sizeStr string) (int64, error) {
|
|||||||
//
|
//
|
||||||
// 返回值:
|
// 返回值:
|
||||||
// - string: 格式化后的字符串,如 "1mb", "10kb" 等
|
// - string: 格式化后的字符串,如 "1mb", "10kb" 等
|
||||||
func FormatSize(size int64) string {
|
func formatSize(size int64) string {
|
||||||
const (
|
const (
|
||||||
KB = 1024
|
KB = 1024
|
||||||
MB = 1024 * KB
|
MB = 1024 * KB
|
||||||
|
|||||||
@ -62,10 +62,10 @@ func TestFormatSize(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(FormatSize(tt.input), func(t *testing.T) {
|
t.Run(formatSize(tt.input), func(t *testing.T) {
|
||||||
got := FormatSize(tt.input)
|
got := formatSize(tt.input)
|
||||||
if got != tt.expected {
|
if got != tt.expected {
|
||||||
t.Errorf("FormatSize(%d) = %s, want %s", tt.input, got, tt.expected)
|
t.Errorf("formatSize(%d) = %s, want %s", tt.input, got, tt.expected)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user