mirror of
https://github.com/stakater/Reloader.git
synced 2026-05-16 21:56:55 +00:00
Fix formatting
Signed-off-by: faizanahmad055 <faizan.ahmad55@outlook.com>
This commit is contained in:
@@ -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{}{}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user