Fix formatting

Signed-off-by: faizanahmad055 <faizan.ahmad55@outlook.com>
This commit is contained in:
faizanahmad055
2026-05-11 22:36:46 +02:00
parent 2d1c05ef5e
commit 90f0768f56
2 changed files with 20 additions and 18 deletions

View File

@@ -58,7 +58,9 @@ var selectedNamespacesCache atomic.Value // always stores map[string]struct{}
// loadSelectedNamespaces returns the current namespace snapshot (never nil).
func loadSelectedNamespaces() map[string]struct{} {
if v := selectedNamespacesCache.Load(); v != nil {
return v.(map[string]struct{})
if m, ok := v.(map[string]struct{}); ok {
return m
}
}
return map[string]struct{}{}
}

View File

@@ -223,12 +223,12 @@ func TestResourceInSelectedNamespaces(t *testing.T) {
for _, tt := range tests {
t.Run(
tt.name, func(t *testing.T) {
resetGlobalState()
storeSelectedNamespaces(tt.cachedNamespaces)
resetGlobalState()
storeSelectedNamespaces(tt.cachedNamespaces)
c := newTestController([]string{}, tt.namespaceSelector)
result := c.resourceInSelectedNamespaces(tt.resource)
assert.Equal(t, tt.expected, result)
c := newTestController([]string{}, tt.namespaceSelector)
result := c.resourceInSelectedNamespaces(tt.resource)
assert.Equal(t, tt.expected, result)
},
)
}
@@ -293,16 +293,16 @@ func TestRemoveSelectedNamespaceFromCache(t *testing.T) {
for _, tt := range tests {
t.Run(
tt.name, func(t *testing.T) {
resetGlobalState()
storeSelectedNamespaces(tt.initialCache)
resetGlobalState()
storeSelectedNamespaces(tt.initialCache)
c := newTestController([]string{}, "env=prod")
ns := v1.Namespace{
ObjectMeta: metav1.ObjectMeta{Name: tt.namespaceToRemove},
}
c.removeSelectedNamespaceFromCache(ns)
c := newTestController([]string{}, "env=prod")
ns := v1.Namespace{
ObjectMeta: metav1.ObjectMeta{Name: tt.namespaceToRemove},
}
c.removeSelectedNamespaceFromCache(ns)
assert.ElementsMatch(t, tt.expectedCache, loadSelectedNamespacesList())
assert.ElementsMatch(t, tt.expectedCache, loadSelectedNamespacesList())
},
)
}
@@ -500,10 +500,10 @@ func TestUpdateHandler(t *testing.T) {
for _, tt := range tests {
t.Run(
tt.name, func(t *testing.T) {
resetGlobalState()
if tt.cachedNamespaces != nil {
storeSelectedNamespaces(tt.cachedNamespaces)
}
resetGlobalState()
if tt.cachedNamespaces != nil {
storeSelectedNamespaces(tt.cachedNamespaces)
}
c := newTestController(tt.ignoredNamespaces, tt.namespaceSelector)
c.Update(tt.oldResource, tt.newResource)