-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The indicator sometimes says something is large, despite the fact it is actually quite small. Example: if 1 out of 2 assets is affected, the indicator says blast radius is large. This new mechanism sets strict breakpoints before something is considered large in its effect. Signed-off-by: Dominik Richter <[email protected]>
- Loading branch information
Showing
2 changed files
with
52 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (c) Mondoo, Inc. | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
|
||
package policy | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestBlastRadius(t *testing.T) { | ||
conf := DefaultBlastRadiusConfig | ||
tests := []struct { | ||
n float32 | ||
max float32 | ||
indicator string | ||
}{ | ||
{1, 100, "s"}, | ||
{10, 100, "m"}, | ||
{30, 100, "l"}, | ||
{4, 5, "s"}, | ||
{10, 20, "m"}, | ||
{50, 100, "l"}, | ||
} | ||
|
||
for i := range tests { | ||
test := tests[i] | ||
t.Run(fmt.Sprintf("%.2f / %.2f => %s", test.n, test.max, test.indicator), func(t *testing.T) { | ||
assert.Equal(t, test.indicator, string(conf.Indicator(test.max, test.n))) | ||
}) | ||
} | ||
} |