2019-05-10 00:05:21 -07:00
|
|
|
package event
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"gotest.tools/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestPositive(t *testing.T) {
|
|
|
|
resourceName := "test_resource"
|
2020-07-20 08:00:02 -07:00
|
|
|
ruleName := "test_rule"
|
|
|
|
expectedMsg := fmt.Sprintf("Rule(s) '%s' failed to apply on resource %s", ruleName, resourceName)
|
2021-06-30 00:43:11 +03:00
|
|
|
msg, err := getEventMsg(FPolicyApply, ruleName, resourceName)
|
2019-05-10 00:05:21 -07:00
|
|
|
assert.NilError(t, err)
|
|
|
|
assert.Equal(t, expectedMsg, msg)
|
|
|
|
}
|
|
|
|
|
|
|
|
// passing incorrect args
|
|
|
|
func TestIncorrectArgs(t *testing.T) {
|
|
|
|
resourceName := "test_resource"
|
2021-06-30 00:43:11 +03:00
|
|
|
_, err := getEventMsg(FPolicyApply, resourceName, "extra_args1", "extra_args2")
|
2020-07-20 08:00:02 -07:00
|
|
|
assert.Error(t, err, "message expects 2 arguments, but 3 arguments passed")
|
2019-05-10 00:05:21 -07:00
|
|
|
}
|