fix(promunifi): default an unset http_listen instead of failing validation

This commit is contained in:
Iain
2026-09-03 01:12:20 +01:00
parent 4e3c58a79a
commit e2384b8bb8
2 changed files with 23 additions and 1 deletions
+1 -1
View File
@@ -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
+22
View File
@@ -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)
}