-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
builtin: Return evalerrors.ErrEvaluationSkipSilently in case the buil…
…tin evaluator doesn't match the entity Returning `nil, nil` is wrong as it would be treated the same as "evaluation was performed an no issues were found"
- Loading branch information
Showing
2 changed files
with
38 additions
and
9 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,32 @@ | ||
package builtin | ||
|
||
import ( | ||
"context" | ||
evalerrors "github.com/stacklok/mediator/internal/engine/errors" | ||
pb "github.com/stacklok/mediator/pkg/generated/protobuf/go/mediator/v1" | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
|
||
"google.golang.org/protobuf/reflect/protoreflect" | ||
) | ||
|
||
type fakeMethods struct{} | ||
|
||
func (fm *fakeMethods) Test(ctx context.Context, ent protoreflect.ProtoMessage, params map[string]any) (any, error) { | ||
return nil, nil | ||
} | ||
|
||
func TestNewBuiltinRuleDataIngestNoMatch(t *testing.T) { | ||
bi, err := NewBuiltinRuleDataIngest(nil, "") | ||
assert.NoError(t, err) | ||
|
||
// set the rule methods to a fake | ||
bi.ruleMethods = &fakeMethods{} | ||
bi.method = "Test" | ||
|
||
res, err := bi.Ingest(context.Background(), &pb.Artifact{}, map[string]any{ | ||
"foo": "bar", | ||
}) | ||
assert.Equal(t, evalerrors.ErrEvaluationSkipSilently, err) | ||
assert.Nil(t, res) | ||
} |