mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-10 20:05:55 +02:00
add if test
This commit is contained in:
parent
225d89ded2
commit
a1cdc52c23
1 changed files with 15 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
|||
//go:build expr_debug
|
||||
|
||||
package exprhelpers
|
||||
|
||||
import (
|
||||
|
@ -273,6 +274,20 @@ func TestBaseDbg(t *testing.T) {
|
|||
{Code: "and", CodeDepth: 0, JumpIf: true, IfFalse: true, StrConditionResult: "false", ConditionResult: boolPtr(false), Finalized: true},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "if",
|
||||
Expr: `if base_int != 42 {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}`,
|
||||
Env: defaultEnv,
|
||||
ExpectedOutputs: []OpOutput{
|
||||
{Code: "!= 42 {", CodeDepth: 0, Negated: true, Comparison: true, Left: "42", Right: "42", StrConditionResult: "[true]", ConditionResult: boolPtr(true), Finalized: true},
|
||||
{Code: "if base_int != 42 {", CodeDepth: 0, ConditionResult: boolPtr(false), Finalized: false, IfFalse: true, JumpIf: true, StrConditionResult: "false"},
|
||||
{Code: "false }", CodeDepth: 0, StrConditionResult: "false", Condition: true, ConditionResult: boolPtr(false), Finalized: true},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
logger := log.WithField("test", "exprhelpers")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue