fixed tests

This commit is contained in:
Mike Farah 2021-11-30 13:16:35 +11:00
parent bb0e6fb857
commit d80054dcc6
2 changed files with 10 additions and 9 deletions

View File

@ -91,21 +91,14 @@ Given a sample.yml file of:
a: 1 a: 1
b: 2 b: 2
``` ```
And another sample another.yml file of:
```yaml
c: 1
d: 2
```
then then
```bash ```bash
yq eval-all 'with_entries(.key |= "KEY_" + .)' sample.yml another.yml yq eval 'with_entries(.key |= "KEY_" + .)' sample.yml
``` ```
will output will output
```yaml ```yaml
KEY_a: 1 KEY_a: 1
KEY_b: 2 KEY_b: 2
KEY_c: 1
KEY_d: 2
``` ```
## Use with_entries to filter the map ## Use with_entries to filter the map

View File

@ -47,8 +47,16 @@ var entriesOperatorScenarios = []expressionScenario{
{ {
description: "Use with_entries to update keys", description: "Use with_entries to update keys",
document: `{a: 1, b: 2}`, document: `{a: 1, b: 2}`,
document2: `{c: 1, d: 2}`,
expression: `with_entries(.key |= "KEY_" + .)`, expression: `with_entries(.key |= "KEY_" + .)`,
expected: []string{
"D0, P[], (!!map)::KEY_a: 1\nKEY_b: 2\n",
},
},
{
skipDoc: true,
document: `{a: 1, b: 2}`,
document2: `{c: 1, d: 2}`,
expression: `with_entries(.key |= "KEY_" + .)`,
expected: []string{ expected: []string{
"D0, P[], (!!map)::KEY_a: 1\nKEY_b: 2\n", "D0, P[], (!!map)::KEY_a: 1\nKEY_b: 2\n",
"D0, P[], (!!map)::KEY_c: 1\nKEY_d: 2\n", "D0, P[], (!!map)::KEY_c: 1\nKEY_d: 2\n",