Fixing entries test

This commit is contained in:
Mike Farah 2021-06-08 21:50:14 +10:00
parent ed377a032d
commit 01e478e81d
2 changed files with 8 additions and 6 deletions

View File

@ -98,7 +98,8 @@ KEY_a: 1
KEY_b: 2
```
Using with_entries is also useful whe you want to filter a map. Given a sample.yml file of:
## Use with_entries to filter the map
Given a sample.yml file of:
```yaml
a:
b: bird
@ -113,4 +114,5 @@ will output
```yaml
a:
b: bird
```
```

View File

@ -53,11 +53,11 @@ var entriesOperatorScenarios = []expressionScenario{
},
},
{
description: "Use with_entries to filter keys",
document: `{a: b: "bird", c: d: "dog"}`,
expression: `with_entries(.value | has("b"))`,
description: "Use with_entries to filter the map",
document: `{a: { b: bird }, c: { d: dog }}`,
expression: `with_entries(select(.value | has("b")))`,
expected: []string{
"D0, P[], (!!map)::a:\n b: \"bird\"\n",
"D0, P[], (!!map)::a: {b: bird}\n",
},
},
}