test(models): Consolidate mock input implementations (#16424)

This commit is contained in:
Sven Rebhan 2025-01-22 20:57:08 +01:00 committed by GitHub
parent 4b49d9fbb9
commit b074f0893d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 19 deletions

View File

@ -488,18 +488,8 @@ func TestRunningInputMakeMetricWithGatherEndTimeSource(t *testing.T) {
require.Equal(t, expected, actual)
}
type mockInput struct{}
func (*mockInput) SampleConfig() string {
return ""
}
func (*mockInput) Gather(telegraf.Accumulator) error {
return nil
}
func TestRunningInputProbingFailure(t *testing.T) {
ri := NewRunningInput(&mockProbingInput{
ri := NewRunningInput(&mockInput{
probeReturn: errors.New("probing error"),
}, &InputConfig{
Name: "TestRunningInput",
@ -528,7 +518,7 @@ func TestRunningInputProbingSuccess(t *testing.T) {
},
{
name: "probing plugin with probe value not set",
input: &mockProbingInput{probeErr},
input: &mockInput{probeErr},
startupErrorBehavior: "ignore",
},
} {
@ -543,18 +533,18 @@ func TestRunningInputProbingSuccess(t *testing.T) {
}
}
type mockProbingInput struct {
type mockInput struct {
probeReturn error
}
func (m *mockProbingInput) SampleConfig() string {
func (*mockInput) SampleConfig() string {
return ""
}
func (m *mockProbingInput) Gather(_ telegraf.Accumulator) error {
return nil
}
func (m *mockProbingInput) Probe() error {
func (m *mockInput) Probe() error {
return m.probeReturn
}
func (*mockInput) Gather(telegraf.Accumulator) error {
return nil
}