mirror of
https://github.com/storytold/irsa-manager.git
synced 2026-10-09 00:09:43 +00:00
fix status settings
This commit is contained in:
@@ -87,7 +87,7 @@ type StatusServiceAccountList []IRSANamespacedNameWithTags
|
|||||||
|
|
||||||
func (s *StatusServiceAccountList) IsExist(nsNames types.NamespacedName) bool {
|
func (s *StatusServiceAccountList) IsExist(nsNames types.NamespacedName) bool {
|
||||||
return slices.ContainsFunc(*s, func(sa IRSANamespacedNameWithTags) bool {
|
return slices.ContainsFunc(*s, func(sa IRSANamespacedNameWithTags) bool {
|
||||||
return sa.Name == nsNames.Name && sa.Name == nsNames.Namespace
|
return sa.Name == nsNames.Name && sa.Namespace == nsNames.Namespace
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -83,3 +83,45 @@ func TestStatusServiceAccountList_Delete(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestStatusServiceAccountList_IsExist(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
initial StatusServiceAccountList
|
||||||
|
toCheck types.NamespacedName
|
||||||
|
expected bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "Item exists",
|
||||||
|
initial: StatusServiceAccountList{
|
||||||
|
{Name: "existing", Namespace: "default"},
|
||||||
|
{Name: "another", Namespace: "default"},
|
||||||
|
},
|
||||||
|
toCheck: types.NamespacedName{Name: "existing", Namespace: "default"},
|
||||||
|
expected: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Item does not exist",
|
||||||
|
initial: StatusServiceAccountList{
|
||||||
|
{Name: "existing", Namespace: "default"},
|
||||||
|
},
|
||||||
|
toCheck: types.NamespacedName{Name: "nonexisting", Namespace: "default"},
|
||||||
|
expected: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Item with different namespace",
|
||||||
|
initial: StatusServiceAccountList{
|
||||||
|
{Name: "existing", Namespace: "default"},
|
||||||
|
},
|
||||||
|
toCheck: types.NamespacedName{Name: "existing", Namespace: "othernamespace"},
|
||||||
|
expected: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
result := tt.initial.IsExist(tt.toCheck)
|
||||||
|
assert.Equal(t, tt.expected, result)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user