Files
lislgosms/gateway/internal/inbound/http_client_test.go
T

29 lines
864 B
Go

package inbound
import (
"net/http"
"testing"
)
func TestNewAPIHTTPClientMatchesBoundedSubmitConcurrency(t *testing.T) {
client := NewAPIHTTPClient(48)
transport, ok := client.Transport.(*http.Transport)
if !ok {
t.Fatalf("expected *http.Transport, got %T", client.Transport)
}
if transport.MaxConnsPerHost != 48 || transport.MaxIdleConnsPerHost != 48 {
t.Fatalf("unexpected host connection bounds: max=%d idle=%d", transport.MaxConnsPerHost, transport.MaxIdleConnsPerHost)
}
if client.Timeout != defaultHTTPTimeout {
t.Fatalf("unexpected client timeout: %s", client.Timeout)
}
}
func TestNewAPIHTTPClientUsesSafeDefault(t *testing.T) {
client := NewAPIHTTPClient(0)
transport := client.Transport.(*http.Transport)
if transport.MaxConnsPerHost != 64 {
t.Fatalf("expected default max connections 64, got %d", transport.MaxConnsPerHost)
}
}