diff --git a/pkg/inputunifi/remote.go b/pkg/inputunifi/remote.go index f05ee105..aa220f6b 100644 --- a/pkg/inputunifi/remote.go +++ b/pkg/inputunifi/remote.go @@ -177,7 +177,7 @@ func (u *InputUnifi) discoverRemoteControllers(apiKey string) ([]*Controller, er // checkSites / getFilteredSites match against legacy Site.Name, which is // RemoteSite.InternalReference, not the display Name. See unpoller/unpoller#986. - siteNames := remoteSitePollNames(sites) + siteNames := RemoteSitePollNames(sites) // For Cloud Gateways, if the only site is "default", use the console name from hosts response // as the default site name override. The console name is in reportedState.name @@ -204,16 +204,16 @@ func (u *InputUnifi) discoverRemoteControllers(apiKey string) ([]*Controller, er controller.ID = console.ID controllers = append(controllers, controller) - u.Logf("Discovered console %s with %d site(s): %v", consoleName, len(sites), formatRemoteSites(sites)) + u.Logf("Discovered console %s with %d site(s): %v", consoleName, len(sites), FormatRemoteSites(sites)) } return controllers, nil } -// remoteSitePollNames returns the legacy site identifiers used by checkSites +// RemoteSitePollNames returns the legacy site identifiers used by checkSites // and getFilteredSites. Prefer InternalReference (OpenAPI Site overview); // fall back to Name when the field is missing (older firmware). -func remoteSitePollNames(sites []unifi.RemoteSite) []string { +func RemoteSitePollNames(sites []unifi.RemoteSite) []string { names := make([]string, 0, len(sites)) for _, site := range sites { @@ -230,8 +230,8 @@ func remoteSitePollNames(sites []unifi.RemoteSite) []string { return names } -// formatRemoteSites logs display name plus legacy id when they differ. -func formatRemoteSites(sites []unifi.RemoteSite) []string { +// FormatRemoteSites logs display name plus legacy id when they differ. +func FormatRemoteSites(sites []unifi.RemoteSite) []string { out := make([]string, 0, len(sites)) for _, site := range sites { diff --git a/pkg/inputunifi/remote_test.go b/pkg/inputunifi/remote_test.go index 0c981d10..9467a4c1 100644 --- a/pkg/inputunifi/remote_test.go +++ b/pkg/inputunifi/remote_test.go @@ -1,10 +1,11 @@ -package inputunifi +package inputunifi_test import ( "testing" "github.com/stretchr/testify/assert" "github.com/unpoller/unifi/v6" + "github.com/unpoller/unpoller/pkg/inputunifi" ) func TestRemoteSitePollNames(t *testing.T) { @@ -48,7 +49,8 @@ func TestRemoteSitePollNames(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { t.Parallel() - assert.Equal(t, tt.want, remoteSitePollNames(tt.sites)) + + assert.Equal(t, tt.want, inputunifi.RemoteSitePollNames(tt.sites)) }) } } @@ -68,5 +70,5 @@ func TestFormatRemoteSites(t *testing.T) { "Office (abc1def2)", "only-id", "legacy-name-only", - }, formatRemoteSites(sites)) + }, inputunifi.FormatRemoteSites(sites)) }