github.com/Ingenico-ePayments/connect-sdk-go@v0.0.0-20240318153750-1f8cd329b9c9/defaultimpl/DefaultConnection_test.go (about)

     1  package defaultimpl
     2  
     3  import (
     4  	"net/http"
     5  	"testing"
     6  	"time"
     7  )
     8  
     9  const socketTimeout = 10000 * time.Microsecond
    10  const connectTimeout = 100 * time.Microsecond
    11  const keepAliveTimeout = 100 * time.Microsecond
    12  const idleTimeout = 10 * time.Second
    13  const maxConnections = 100
    14  
    15  func TestConstructWithoutProxy(t *testing.T) {
    16  	connection, _ := NewDefaultConnection(socketTimeout, connectTimeout, keepAliveTimeout, idleTimeout, maxConnections, nil)
    17  	// Cannot recover connectTimeout, because it is embedded in the dial function
    18  
    19  	// Cannot recover proxy, because it is embedded in a function that is never nil, and functions also cannot be compared in go
    20  	if transport, ok := connection.client.Transport.(*http.Transport); ok {
    21  		if transport.MaxIdleConns != maxConnections {
    22  			t.Fatal("Max connections not used")
    23  		}
    24  	}
    25  
    26  	if connection.client.Timeout != socketTimeout {
    27  		t.Fatal("Socket timeout not used")
    28  	}
    29  }