-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: emit error event when expression engine return parsing errors (#…
…2311) * make expression parser return a InvalidSyntaxError * emit event in case of syntax error
- Loading branch information
1 parent
b9b6103
commit 125db30
Showing
6 changed files
with
75 additions
and
11 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
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
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 expression_test | ||
|
||
import ( | ||
"errors" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/kubeshop/tracetest/server/expression" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestStatementParsingErrors(t *testing.T) { | ||
executor := expression.NewExecutor() | ||
_, _, err := executor.Statement(`1 1 + = 2`) | ||
|
||
assert.Error(t, err) | ||
assert.True(t, strings.HasPrefix(err.Error(), `invalid syntax "1 1 + = 2": `)) | ||
|
||
unwrappedErr := errors.Unwrap(err) | ||
assert.False(t, strings.HasPrefix(unwrappedErr.Error(), `invalid syntax "1 1 + = 2": `)) | ||
} | ||
|
||
func TestExpressionParsingErrors(t *testing.T) { | ||
executor := expression.NewExecutor() | ||
_, err := executor.Expression(`attr:attribute env:number`) | ||
|
||
assert.Error(t, err) | ||
assert.True(t, strings.HasPrefix(err.Error(), `invalid syntax "attr:attribute env:number": `)) | ||
|
||
unwrappedErr := errors.Unwrap(err) | ||
assert.False(t, strings.HasPrefix(unwrappedErr.Error(), `invalid syntax "attr:attribute env:number": `)) | ||
} |
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