Merge pull request #1077 from NotAFlightRisk/fix/health-check-empty-http-listen

This commit is contained in:
Cody Lee
2026-09-02 20:40:31 -04:00
committed by GitHub
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)
}