chore: 项目基线(基于 WeKnora 定制版,整理文件忽略规则)
This commit is contained in:
commit
9097ee699d
5769 files changed
+1446466
No files matched your search
@@ -0,0 +1,32 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// TestOutboundDialTimeoutDefault verifies the package default is 5s.
|
||||
// Keep these tests serial: they read and mutate the same process-wide timeout.
|
||||
func TestOutboundDialTimeoutDefault(t *testing.T) {
|
||||
if got := OutboundDialTimeout(); got != 5*time.Second {
|
||||
t.Fatalf("default dial timeout = %v, want %v", got, 5*time.Second)
|
||||
}
|
||||
}
|
||||
|
||||
// TestSetOutboundDialTimeout verifies the setter is reflected by the getter and
|
||||
// that non-positive values are ignored.
|
||||
func TestSetOutboundDialTimeout(t *testing.T) {
|
||||
original := OutboundDialTimeout()
|
||||
t.Cleanup(func() { SetOutboundDialTimeout(original) })
|
||||
|
||||
SetOutboundDialTimeout(2 * time.Second)
|
||||
if got := OutboundDialTimeout(); got != 2*time.Second {
|
||||
t.Fatalf("after set 2s: got %v, want %v", got, 2*time.Second)
|
||||
}
|
||||
|
||||
// Non-positive must be ignored, leaving the previous value intact.
|
||||
SetOutboundDialTimeout(0)
|
||||
if got := OutboundDialTimeout(); got != 2*time.Second {
|
||||
t.Fatalf("after set 0: got %v, want %v (value should be unchanged)", got, 2*time.Second)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user