add new interface for testing

This commit is contained in:
Cody Lee
2022-12-22 17:44:39 -06:00
parent a5f858c23a
commit db9bcd5687
11 changed files with 201 additions and 6 deletions

View File

@@ -3,6 +3,7 @@
package datadogunifi
import (
"fmt"
"reflect"
"time"
@@ -203,6 +204,22 @@ func (u *DatadogUnifi) Enabled() bool {
return *u.Enable
}
func (u *DatadogUnifi) DebugOutput(l poller.Logger) (bool, error) {
if u == nil {
return true, nil
}
if !u.Enabled() {
return true, nil
}
u.setConfigDefaults()
var err error
u.datadog, err = statsd.New(u.Address, u.options...)
if err != nil {
return false, fmt.Errorf("Error configuration Datadog agent reporting: %+v", err)
}
return true, nil
}
// Run runs a ticker to poll the unifi server and update Datadog.
func (u *DatadogUnifi) Run(c poller.Collect) error {
u.Collector = c