github.com/blend/go-sdk@v1.20220411.3/proxyprotocol/create_listener_options_test.go (about)

     1  /*
     2  
     3  Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file.
     5  
     6  */
     7  
     8  package proxyprotocol
     9  
    10  import (
    11  	"crypto/tls"
    12  	"testing"
    13  	"time"
    14  
    15  	"github.com/blend/go-sdk/assert"
    16  )
    17  
    18  func TestCreateListenerOptions(t *testing.T) {
    19  	assert := assert.New(t)
    20  
    21  	var options CreateListenerOptions
    22  
    23  	assert.False(options.KeepAlive)
    24  	assert.Nil(OptKeepAlive(true)(&options))
    25  	assert.True(options.KeepAlive)
    26  
    27  	assert.Zero(options.KeepAlivePeriod)
    28  	assert.Nil(OptKeepAlivePeriod(time.Second)(&options))
    29  	assert.Equal(time.Second, options.KeepAlivePeriod)
    30  
    31  	assert.False(options.UseProxyProtocol)
    32  	assert.Nil(OptUseProxyProtocol(true)(&options))
    33  	assert.True(options.UseProxyProtocol)
    34  
    35  	assert.Nil(options.TLSConfig)
    36  	assert.Nil(OptTLSConfig(&tls.Config{})(&options))
    37  	assert.NotNil(options.TLSConfig)
    38  }