Skip to content

Commit 3a5a76f

Browse files
committed
add output to test
1 parent 1651558 commit 3a5a76f

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

internal/pkg/agent/application/coordinator/testdata/overrides.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,11 @@ agent:
55
logs: false
66
metrics: true
77
http:
8-
port: 6774
8+
port: 6774
9+
outputs:
10+
default:
11+
type: kafka
12+
hosts: localhost
13+
api_key: ""
14+
username: ""
15+
password: ""

internal/pkg/agent/application/fleet_config_patcher_test.go

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,16 @@ func Test_FleetPatcher(t *testing.T) {
2222
configFile := filepath.Join(".", "coordinator", "testdata", "overrides.yml")
2323

2424
testCases := []struct {
25-
name string
26-
isManaged bool
27-
featureEnable bool
28-
expectedLogs bool
25+
name string
26+
isManaged bool
27+
featureEnable bool
28+
expectedLogs bool
29+
expectedOutputType string
2930
}{
30-
{name: "managed - enabled", isManaged: true, featureEnable: true, expectedLogs: false},
31-
{name: "managed - disabled", isManaged: true, featureEnable: false, expectedLogs: true},
32-
{name: "not managed - enabled", isManaged: false, featureEnable: true, expectedLogs: true},
33-
{name: "not managed - disabled", isManaged: false, featureEnable: false, expectedLogs: true},
31+
{name: "managed - enabled", isManaged: true, featureEnable: true, expectedLogs: false, expectedOutputType: "kafka"},
32+
{name: "managed - disabled", isManaged: true, featureEnable: false, expectedLogs: true, expectedOutputType: "elasticsearch"},
33+
{name: "not managed - enabled", isManaged: false, featureEnable: true, expectedLogs: true, expectedOutputType: "elasticsearch"},
34+
{name: "not managed - disabled", isManaged: false, featureEnable: false, expectedLogs: true, expectedOutputType: "elasticsearch"},
3435
}
3536

3637
overridesFile, err := os.OpenFile(configFile, os.O_RDONLY, 0)
@@ -62,6 +63,17 @@ func Test_FleetPatcher(t *testing.T) {
6263
assert.Equal(t, tc.expectedLogs, c.Settings.MonitoringConfig.MonitorLogs)
6364
require.True(t, c.Settings.MonitoringConfig.MonitorMetrics)
6465
require.True(t, c.Settings.MonitoringConfig.Enabled)
66+
67+
// make sure output is not kafka
68+
oc, err := cfg.Agent.Child("outputs", -1)
69+
require.NoError(t, err)
70+
71+
do, err := oc.Child("default", -1)
72+
require.NoError(t, err)
73+
74+
outputType, err := do.String("type", -1)
75+
require.NoError(t, err)
76+
assert.Equal(t, tc.expectedOutputType, outputType, "output type should be %s, got %s", tc.expectedOutputType, outputType)
6577
})
6678
}
6779
}

0 commit comments

Comments
 (0)