|
| 1 | +package config |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + "time" |
| 6 | + |
| 7 | + "github.com/panjf2000/gnet/v2" |
| 8 | + "github.com/rs/zerolog" |
| 9 | + "github.com/stretchr/testify/assert" |
| 10 | +) |
| 11 | + |
| 12 | +// TestGetVerificationPolicy tests the GetVerificationPolicy function. |
| 13 | +func TestGetVerificationPolicy(t *testing.T) { |
| 14 | + pluginConfig := PluginConfig{} |
| 15 | + assert.Equal(t, PassDown, pluginConfig.GetVerificationPolicy()) |
| 16 | +} |
| 17 | + |
| 18 | +// TestGetPluginCompatibilityPolicy tests the GetPluginCompatibilityPolicy function. |
| 19 | +func TestGetPluginCompatibilityPolicy(t *testing.T) { |
| 20 | + pluginConfig := PluginConfig{} |
| 21 | + assert.Equal(t, Strict, pluginConfig.GetPluginCompatibilityPolicy()) |
| 22 | +} |
| 23 | + |
| 24 | +// TestGetAcceptancePolicy tests the GetAcceptancePolicy function. |
| 25 | +func TestGetAcceptancePolicy(t *testing.T) { |
| 26 | + pluginConfig := PluginConfig{} |
| 27 | + assert.Equal(t, Accept, pluginConfig.GetAcceptancePolicy()) |
| 28 | +} |
| 29 | + |
| 30 | +// TestGetTerminationPolicy tests the GetTerminationPolicy function. |
| 31 | +func TestGetTerminationPolicy(t *testing.T) { |
| 32 | + pluginConfig := PluginConfig{} |
| 33 | + assert.Equal(t, Stop, pluginConfig.GetTerminationPolicy()) |
| 34 | +} |
| 35 | + |
| 36 | +// TestGetTCPKeepAlivePeriod tests the GetTCPKeepAlivePeriod function. |
| 37 | +func TestGetTCPKeepAlivePeriod(t *testing.T) { |
| 38 | + client := Client{} |
| 39 | + assert.Equal(t, DefaultTCPKeepAlivePeriod, client.GetTCPKeepAlivePeriod()) |
| 40 | +} |
| 41 | + |
| 42 | +// TestGetReceiveDeadline tests the GetReceiveDeadline function. |
| 43 | +func TestGetReceiveDeadline(t *testing.T) { |
| 44 | + client := Client{} |
| 45 | + assert.Equal(t, time.Duration(0), client.GetReceiveDeadline()) |
| 46 | +} |
| 47 | + |
| 48 | +// TestGetReceiveTimeout tests the GetReceiveTimeout function. |
| 49 | +func TestGetReceiveTimeout(t *testing.T) { |
| 50 | + client := Client{} |
| 51 | + assert.Equal(t, time.Duration(0), client.GetReceiveTimeout()) |
| 52 | +} |
| 53 | + |
| 54 | +// TestGetSendDeadline tests the GetSendDeadline function. |
| 55 | +func TestGetSendDeadline(t *testing.T) { |
| 56 | + client := Client{} |
| 57 | + assert.Equal(t, time.Duration(0), client.GetSendDeadline()) |
| 58 | +} |
| 59 | + |
| 60 | +// TestGetReceiveChunkSize tests the GetReceiveChunkSize function. |
| 61 | +func TestGetReceiveChunkSize(t *testing.T) { |
| 62 | + client := Client{} |
| 63 | + assert.Equal(t, DefaultChunkSize, client.GetReceiveChunkSize()) |
| 64 | +} |
| 65 | + |
| 66 | +// TestGetHealthCheckPeriod tests the GetHealthCheckPeriod function. |
| 67 | +func TestGetHealthCheckPeriod(t *testing.T) { |
| 68 | + proxy := Proxy{} |
| 69 | + assert.Equal(t, DefaultHealthCheckPeriod, proxy.GetHealthCheckPeriod()) |
| 70 | +} |
| 71 | + |
| 72 | +// TestGetTickInterval tests the GetTickInterval function. |
| 73 | +func TestGetTickInterval(t *testing.T) { |
| 74 | + server := Server{} |
| 75 | + assert.Equal(t, DefaultTickInterval, server.GetTickInterval()) |
| 76 | +} |
| 77 | + |
| 78 | +// TestGetLoadBalancer tests the GetLoadBalancer function. |
| 79 | +func TestGetLoadBalancer(t *testing.T) { |
| 80 | + server := Server{} |
| 81 | + assert.Equal(t, gnet.RoundRobin, server.GetLoadBalancer()) |
| 82 | +} |
| 83 | + |
| 84 | +// TestGetTCPNoDelay tests the GetTCPNoDelay function. |
| 85 | +func TestGetTCPNoDelay(t *testing.T) { |
| 86 | + server := Server{} |
| 87 | + assert.Equal(t, gnet.TCPDelay, server.GetTCPNoDelay()) |
| 88 | +} |
| 89 | + |
| 90 | +// TestGetSize tests the GetSize function. |
| 91 | +func TestGetSize(t *testing.T) { |
| 92 | + pool := Pool{} |
| 93 | + assert.Equal(t, DefaultPoolSize, pool.GetSize()) |
| 94 | +} |
| 95 | + |
| 96 | +// TestGetOutput tests the GetOutput function. |
| 97 | +func TestGetOutput(t *testing.T) { |
| 98 | + logger := Logger{} |
| 99 | + assert.Equal(t, []LogOutput{Console}, logger.GetOutput()) |
| 100 | +} |
| 101 | + |
| 102 | +// TestGetTimeFormat tests the GetTimeFormat function. |
| 103 | +func TestGetTimeFormat(t *testing.T) { |
| 104 | + logger := Logger{} |
| 105 | + assert.Equal(t, zerolog.TimeFormatUnix, logger.GetTimeFormat()) |
| 106 | +} |
| 107 | + |
| 108 | +// TestGetConsoleTimeFormat tests the GetConsoleTimeFormat function. |
| 109 | +func TestGetConsoleTimeFormat(t *testing.T) { |
| 110 | + logger := Logger{} |
| 111 | + assert.Equal(t, time.RFC3339, logger.GetConsoleTimeFormat()) |
| 112 | +} |
| 113 | + |
| 114 | +// TestGetLevel tests the GetLevel function. |
| 115 | +func TestGetLevel(t *testing.T) { |
| 116 | + logger := Logger{} |
| 117 | + assert.Equal(t, zerolog.InfoLevel, logger.GetLevel()) |
| 118 | +} |
| 119 | + |
| 120 | +// TestGetPlugins tests the GetPlugins function. |
| 121 | +func TestGetPlugins(t *testing.T) { |
| 122 | + plugin := Plugin{Name: "plugin1"} |
| 123 | + pluginConfig := PluginConfig{Plugins: []Plugin{plugin}} |
| 124 | + assert.Equal(t, []Plugin{plugin}, pluginConfig.GetPlugins("plugin1")) |
| 125 | +} |
| 126 | + |
| 127 | +// TestGetDefaultConfigFilePath tests the GetDefaultConfigFilePath function. |
| 128 | +func TestGetDefaultConfigFilePath(t *testing.T) { |
| 129 | + assert.Equal(t, GlobalConfigFilename, GetDefaultConfigFilePath(GlobalConfigFilename)) |
| 130 | +} |
0 commit comments