trpc.group/trpc-go/trpc-go@v1.0.3/transport/tnet/server_transport_option_test.go (about)

     1  //
     2  //
     3  // Tencent is pleased to support the open source community by making tRPC available.
     4  //
     5  // Copyright (C) 2023 THL A29 Limited, a Tencent company.
     6  // All rights reserved.
     7  //
     8  // If you have downloaded a copy of the tRPC source code from Tencent,
     9  // please note that tRPC source code is licensed under the  Apache 2.0 License,
    10  // A copy of the Apache 2.0 License is included in this file.
    11  //
    12  //
    13  
    14  //go:build linux || freebsd || dragonfly || darwin
    15  // +build linux freebsd dragonfly darwin
    16  
    17  package tnet_test
    18  
    19  import (
    20  	"testing"
    21  	"time"
    22  
    23  	"github.com/stretchr/testify/assert"
    24  
    25  	tnettrans "trpc.group/trpc-go/trpc-go/transport/tnet"
    26  )
    27  
    28  func TestSetNumPollers(t *testing.T) {
    29  	err := tnettrans.SetNumPollers(2)
    30  	assert.Nil(t, err)
    31  }
    32  
    33  func TestOptions(t *testing.T) {
    34  	opts := &tnettrans.ServerTransportOptions{}
    35  	tnettrans.WithKeepAlivePeriod(time.Second)(opts)
    36  	assert.Equal(t, time.Second, opts.KeepAlivePeriod)
    37  }