mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-15 17:51:20 +00:00
63f4c9a884
* Remove unused event.Reason const Signed-off-by: Velkov <valentin.velkov@sap.com> * Generate failure events on policies Signed-off-by: Velkov <valentin.velkov@sap.com> * Generate success events on policy Signed-off-by: Velkov <valentin.velkov@sap.com> * Introduce 'generateSuccessEvents' flag Signed-off-by: Velkov <valentin.velkov@sap.com> * Unit tests & chart fix Signed-off-by: Velkov <valentin.velkov@sap.com>
24 lines
644 B
Go
24 lines
644 B
Go
package event
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"gotest.tools/assert"
|
|
)
|
|
|
|
func TestPositive(t *testing.T) {
|
|
resourceName := "test_resource"
|
|
ruleName := "test_rule"
|
|
expectedMsg := fmt.Sprintf("Rule(s) '%s' failed to apply on resource %s", ruleName, resourceName)
|
|
msg, err := getEventMsg(FPolicyApply, ruleName, resourceName)
|
|
assert.NilError(t, err)
|
|
assert.Equal(t, expectedMsg, msg)
|
|
}
|
|
|
|
// passing incorrect args
|
|
func TestIncorrectArgs(t *testing.T) {
|
|
resourceName := "test_resource"
|
|
_, err := getEventMsg(FPolicyApply, resourceName, "extra_args1", "extra_args2")
|
|
assert.Error(t, err, "message expects 2 arguments, but 3 arguments passed")
|
|
}
|