(goctl)fix: api timeout limited during api generation (#4513)

This commit is contained in:
kesonan
2024-12-19 16:19:10 +08:00
committed by GitHub
parent 9c4ed394a7
commit 6700910f64
5 changed files with 42 additions and 12 deletions

View File

@@ -0,0 +1,27 @@
package gogen
import (
"testing"
"time"
)
func Test_formatDuration(t *testing.T) {
tests := []struct {
duration time.Duration
expected string
}{
{0, "0 * time.Nanosecond"},
{time.Nanosecond, "1 * time.Nanosecond"},
{100 * time.Nanosecond, "100 * time.Nanosecond"},
{500 * time.Microsecond, "500 * time.Microsecond"},
{2 * time.Millisecond, "2 * time.Millisecond"},
{time.Second, "1000 * time.Millisecond"},
}
for _, test := range tests {
result := formatDuration(test.duration)
if result != test.expected {
t.Errorf("formatDuration(%v) = %v; want %v", test.duration, result, test.expected)
}
}
}