Files
Reloader/internal/pkg/cmd/reloader_test.go
T
Nikolaus Schuetz f8c41e4bc8 fix: reflect --namespaces-to-ignore in startup namespace-scope log
When KUBERNETES_NAMESPACE is unset, startReloader logged
"will detect changes in all namespaces." unconditionally, even when
--namespaces-to-ignore was set, which is misleading.

Extract the scope message into namespaceWatchScopeMessage(), move the log
after ignoredNamespacesList is resolved, and include the excluded
namespaces in the message when filtering is active.

Closes #1131

Assisted-by: Claude Code (Anthropic, Opus 4.x)
2026-06-29 12:19:03 -07:00

41 lines
1.3 KiB
Go

package cmd
import "testing"
func TestNamespaceWatchScopeMessage(t *testing.T) {
tests := []struct {
name string
ignoredNamespaces []string
want string
}{
{
name: "no ignored namespaces - all namespaces",
ignoredNamespaces: nil,
want: "KUBERNETES_NAMESPACE is unset, will detect changes in all namespaces.",
},
{
name: "empty ignored namespaces - all namespaces",
ignoredNamespaces: []string{},
want: "KUBERNETES_NAMESPACE is unset, will detect changes in all namespaces.",
},
{
name: "single ignored namespace",
ignoredNamespaces: []string{"kube-system"},
want: "KUBERNETES_NAMESPACE is unset, will detect changes in all namespaces except: kube-system.",
},
{
name: "multiple ignored namespaces",
ignoredNamespaces: []string{"kube-system", "kube-public"},
want: "KUBERNETES_NAMESPACE is unset, will detect changes in all namespaces except: kube-system, kube-public.",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := namespaceWatchScopeMessage(tt.ignoredNamespaces); got != tt.want {
t.Errorf("namespaceWatchScopeMessage(%v) = %q, want %q", tt.ignoredNamespaces, got, tt.want)
}
})
}
}