-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure all boolean output from map is considered (#85)
- Loading branch information
Diego Henrique Oliveira
authored
Apr 28, 2024
1 parent
967fd4b
commit 46da249
Showing
2 changed files
with
38 additions
and
1 deletion.
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,37 @@ | ||
package issues_test | ||
|
||
import ( | ||
"bytes" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/diegoholiveira/jsonlogic/v3" | ||
) | ||
|
||
func TestIssue83(t *testing.T) { | ||
rule := `{ | ||
"map": [ | ||
{"var": "listOfLists"}, | ||
{"in": ["item_a", {"var": ""}]} | ||
] | ||
}` | ||
|
||
data := `{ | ||
"listOfLists": [ | ||
["item_a", "item_b", "item_c"], | ||
["item_b", "item_c"], | ||
["item_a", "item_c"] | ||
] | ||
}` | ||
|
||
var result bytes.Buffer | ||
|
||
err := jsonlogic.Apply(strings.NewReader(rule), strings.NewReader(data), &result) | ||
|
||
if assert.Nil(t, err) { | ||
expected := `[true,false,true]` | ||
assert.JSONEq(t, expected, result.String()) | ||
} | ||
} |