1
0

load_test.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright 2023 The frp Authors
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package config
  15. import (
  16. "testing"
  17. "github.com/stretchr/testify/require"
  18. v1 "github.com/fatedier/frp/pkg/config/v1"
  19. )
  20. func TestLoadConfigure(t *testing.T) {
  21. require := require.New(t)
  22. content := `
  23. bindAddr = "127.0.0.1"
  24. kcpBindPort = 7000
  25. quicBindPort = 7001
  26. tcpmuxHTTPConnectPort = 7005
  27. custom404Page = "/abc.html"
  28. transport.tcpKeepalive = 10
  29. `
  30. svrCfg := v1.ServerConfig{}
  31. err := LoadConfigure([]byte(content), &svrCfg)
  32. require.NoError(err)
  33. require.EqualValues("127.0.0.1", svrCfg.BindAddr)
  34. require.EqualValues(7000, svrCfg.KCPBindPort)
  35. require.EqualValues(7001, svrCfg.QUICBindPort)
  36. require.EqualValues(7005, svrCfg.TCPMuxHTTPConnectPort)
  37. require.EqualValues("/abc.html", svrCfg.Custom404Page)
  38. require.EqualValues(10, svrCfg.Transport.TCPKeepAlive)
  39. }