fix: deployment/cronjob namespace filtering (#290)

Signed-off-by: Matthis Holleville <matthish29@gmail.com>
This commit is contained in:
Matthis
2023-04-17 17:37:19 +02:00
committed by GitHub
parent af8b350520
commit 3d684a2af7
10 changed files with 454 additions and 2 deletions

View File

@@ -145,3 +145,33 @@ func TestStatefulSetAnalyzerMissingStorageClass(t *testing.T) {
}
}
func TestStatefulSetAnalyzerNamespaceFiltering(t *testing.T) {
clientset := fake.NewSimpleClientset(
&appsv1.StatefulSet{
ObjectMeta: metav1.ObjectMeta{
Name: "example",
Namespace: "default",
},
},
&appsv1.StatefulSet{
ObjectMeta: metav1.ObjectMeta{
Name: "example",
Namespace: "other-namespace",
},
})
statefulSetAnalyzer := StatefulSetAnalyzer{}
config := common.Analyzer{
Client: &kubernetes.Client{
Client: clientset,
},
Context: context.Background(),
Namespace: "default",
}
analysisResults, err := statefulSetAnalyzer.Analyze(config)
if err != nil {
t.Error(err)
}
assert.Equal(t, len(analysisResults), 1)
}