Skip to content

Commit 2c61f70

Browse files
kmarteauxzegl
authored andcommitted
Additional test case for multiple ignore annotations
1 parent ba23a2d commit 2c61f70

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

score/score_test.go

+33
Original file line numberDiff line numberDiff line change
@@ -515,3 +515,36 @@ func TestPodEnvDuplicated(t *testing.T) {
515515
diff := cmp.Diff(expected, actual)
516516
assert.Empty(t, diff)
517517
}
518+
519+
func TestMultipleIgnoreAnnotations(t *testing.T) {
520+
t.Parallel()
521+
s, err := testScore(config.Configuration{
522+
VerboseOutput: 0,
523+
AllFiles: []ks.NamedReader{testFile("kube-score-ignore-annotations.yaml")},
524+
UseIgnoreChecksAnnotation: true,
525+
})
526+
assert.Nil(t, err)
527+
assert.Len(t, s, 1)
528+
529+
tested := false
530+
skipped := false
531+
532+
for _, o := range s {
533+
for _, c := range o.Checks {
534+
// implied by the ignore container-resources annotation
535+
if c.Check.ID == "container-ephemeral-storage-request-and-limit" {
536+
assert.True(t, c.Skipped)
537+
skipped = true
538+
}
539+
// a default check
540+
if c.Check.ID == "container-image-pull-policy" {
541+
assert.False(t, c.Skipped)
542+
assert.Equal(t, scorecard.GradeCritical, c.Grade)
543+
tested = true
544+
}
545+
assert.Equal(t, "kube-score-ignore-annotations", o.ObjectMeta.Name)
546+
}
547+
}
548+
assert.True(t, tested)
549+
assert.True(t, skipped)
550+
}

0 commit comments

Comments
 (0)