github.com/TeaOSLab/EdgeNode@v1.3.8/internal/utils/http_test.go (about) 1 package utils 2 3 import ( 4 "github.com/iwind/TeaGo/assert" 5 "testing" 6 "time" 7 ) 8 9 func TestNewHTTPClient(t *testing.T) { 10 a := assert.NewAssertion(t) 11 12 client := NewHTTPClient(1 * time.Second) 13 a.IsTrue(client.Timeout == 1*time.Second) 14 15 client2 := NewHTTPClient(1 * time.Second) 16 a.IsTrue(client != client2) 17 } 18 19 func TestSharedHTTPClient(t *testing.T) { 20 a := assert.NewAssertion(t) 21 22 _ = SharedHttpClient(2 * time.Second) 23 _ = SharedHttpClient(3 * time.Second) 24 25 client := SharedHttpClient(1 * time.Second) 26 a.IsTrue(client.Timeout == 1*time.Second) 27 28 client2 := SharedHttpClient(1 * time.Second) 29 a.IsTrue(client == client2) 30 31 t.Log(timeoutClientMap) 32 }