mirror of
https://github.com/stakater/Reloader.git
synced 2026-08-20 12:36:26 +00:00
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)
41 lines
1.3 KiB
Go
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)
|
|
}
|
|
})
|
|
}
|
|
}
|