Skip to content

Commit

Permalink
test(models): Consolidate mock input implementations (#16424)
Browse files Browse the repository at this point in the history
  • Loading branch information
srebhan authored Jan 22, 2025
1 parent 4b49d9f commit b074f08
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions models/running_input_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
},
} {
Expand All @@ -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 *mockInput) Probe() error {
return m.probeReturn
}

func (m *mockProbingInput) Probe() error {
return m.probeReturn
func (*mockInput) Gather(telegraf.Accumulator) error {
return nil
}

0 comments on commit b074f08

Please sign in to comment.