Skip to content

Commit

Permalink
Add initialization example to mock-plugin. (#8520)
Browse files Browse the repository at this point in the history
  • Loading branch information
srebhan authored Dec 7, 2020
1 parent 1394989 commit d712bd1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions plugins/inputs/mock_Plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
// MockPlugin struct should be named the same as the Plugin
type MockPlugin struct {
mock.Mock

constructedVariable string
}

// Description will appear directly above the plugin definition in the config file
Expand All @@ -21,6 +23,12 @@ func (m *MockPlugin) SampleConfig() string {
return ` sampleVar = 'foo'`
}

// Init can be implemented to do one-time processing stuff like initializing variables
func (m *MockPlugin) Init() error {
m.constructedVariable = "I'm initialized now."
return nil
}

// Gather defines what data the plugin will gather.
func (m *MockPlugin) Gather(_a0 telegraf.Accumulator) error {
ret := m.Called(_a0)
Expand Down

0 comments on commit d712bd1

Please sign in to comment.