Files
EdgeNode/internal/utils/http_test.go

34 lines
653 B
Go
Raw Permalink Normal View History

2020-09-26 08:07:07 +08:00
package utils
import (
"testing"
"time"
2024-07-27 15:42:50 +08:00
"github.com/iwind/TeaGo/assert"
2020-09-26 08:07:07 +08:00
)
func TestNewHTTPClient(t *testing.T) {
a := assert.NewAssertion(t)
client := NewHTTPClient(1 * time.Second)
a.IsTrue(client.Timeout == 1*time.Second)
client2 := NewHTTPClient(1 * time.Second)
a.IsTrue(client != client2)
}
func TestSharedHTTPClient(t *testing.T) {
a := assert.NewAssertion(t)
_ = SharedHttpClient(2 * time.Second)
_ = SharedHttpClient(3 * time.Second)
client := SharedHttpClient(1 * time.Second)
a.IsTrue(client.Timeout == 1*time.Second)
client2 := SharedHttpClient(1 * time.Second)
a.IsTrue(client == client2)
t.Log(timeoutClientMap)
}