trpc.group/trpc-go/trpc-go@v1.0.3/pool/multiplexed/get_options_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 package multiplexed 15 16 import ( 17 "io" 18 "testing" 19 20 "github.com/stretchr/testify/assert" 21 ) 22 23 func TestGetOptions(t *testing.T) { 24 25 opts := NewGetOptions() 26 fp := &emptyFrameParser{} 27 caFile := "caFile" 28 keyFile := "keyFile" 29 serverName := "serverName" 30 certFile := "certFile" 31 localAddr := "127.0.0.1:8080" 32 var id uint32 = 2 33 34 opts.WithFrameParser(fp) 35 opts.WithVID(id) 36 opts.WithDialTLS(certFile, keyFile, caFile, serverName) 37 opts.WithLocalAddr(localAddr) 38 39 assert.Equal(t, opts.FP, fp) 40 assert.Equal(t, opts.VID, id) 41 assert.Equal(t, opts.CACertFile, caFile) 42 assert.Equal(t, opts.TLSKeyFile, keyFile) 43 assert.Equal(t, opts.TLSServerName, serverName) 44 assert.Equal(t, opts.TLSCertFile, certFile) 45 assert.Equal(t, opts.LocalAddr, localAddr) 46 } 47 48 type emptyFrameParser struct{} 49 50 func (efp *emptyFrameParser) Parse(rc io.Reader) (vid uint32, buf []byte, err error) { 51 return 0, nil, nil 52 }