diff --git a/pkg/promunifi/collector.go b/pkg/promunifi/collector.go index 9b82630b..4a2ecc11 100644 --- a/pkg/promunifi/collector.go +++ b/pkg/promunifi/collector.go @@ -234,7 +234,7 @@ func (u *promUnifi) DebugOutput() (bool, error) { } if u.HTTPListen == "" { - return false, fmt.Errorf("invalid listen string") + u.HTTPListen = defaultHTTPListen } // check the port diff --git a/pkg/promunifi/collector_test.go b/pkg/promunifi/collector_test.go new file mode 100644 index 00000000..113ac66e --- /dev/null +++ b/pkg/promunifi/collector_test.go @@ -0,0 +1,22 @@ +//nolint:testpackage // white-box: exercises the unexported output plugin. +package promunifi + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/unpoller/unpoller/pkg/poller" +) + +func TestDebugOutputAcceptsUnsetHTTPListen(t *testing.T) { + poller.SetHealthCheckMode(true) + t.Cleanup(func() { poller.SetHealthCheckMode(false) }) + + u := &promUnifi{Config: &Config{}} + + ok, err := u.DebugOutput() + require.NoError(t, err) + assert.True(t, ok) + assert.Equal(t, defaultHTTPListen, u.HTTPListen) +}