|
15 | 15 | package receivers_test
|
16 | 16 |
|
17 | 17 | import (
|
| 18 | + "fmt" |
18 | 19 | "testing"
|
19 | 20 |
|
20 | 21 | "github.com/stretchr/testify/assert"
|
@@ -82,6 +83,7 @@ func TestDownstreamParsers(t *testing.T) {
|
82 | 83 | {"awsxray", "awsxray", "__awsxray", 2000, false},
|
83 | 84 | {"tcplog", "tcplog", "__tcplog", 0, true},
|
84 | 85 | {"udplog", "udplog", "__udplog", 0, true},
|
| 86 | + {"k8s_cluster", "k8s_cluster", "__k8s_cluster", 0, false}, |
85 | 87 | } {
|
86 | 88 | t.Run(tt.receiverName, func(t *testing.T) {
|
87 | 89 | t.Run("builds successfully", func(t *testing.T) {
|
@@ -143,6 +145,28 @@ func TestDownstreamParsers(t *testing.T) {
|
143 | 145 | assert.EqualValues(t, 65535, ports[0].Port)
|
144 | 146 | assert.Equal(t, naming.PortName(tt.receiverName, int32(tt.defaultPort)), ports[0].Name)
|
145 | 147 | })
|
| 148 | + |
| 149 | + t.Run("returns a default config", func(t *testing.T) { |
| 150 | + // prepare |
| 151 | + parser := receivers.ReceiverFor(tt.receiverName) |
| 152 | + |
| 153 | + // test |
| 154 | + config, err := parser.GetDefaultConfig(logger, map[string]interface{}{}) |
| 155 | + |
| 156 | + // verify |
| 157 | + assert.NoError(t, err) |
| 158 | + configMap, ok := config.(map[string]interface{}) |
| 159 | + assert.True(t, ok) |
| 160 | + if tt.defaultPort == 0 { |
| 161 | + assert.Empty(t, configMap, 0) |
| 162 | + return |
| 163 | + } |
| 164 | + if tt.listenAddrParser { |
| 165 | + assert.Equal(t, configMap["listen_address"], fmt.Sprintf("0.0.0.0:%d", tt.defaultPort)) |
| 166 | + } else { |
| 167 | + assert.Equal(t, configMap["endpoint"], fmt.Sprintf("0.0.0.0:%d", tt.defaultPort)) |
| 168 | + } |
| 169 | + }) |
146 | 170 | })
|
147 | 171 | }
|
148 | 172 | }
|
0 commit comments