mirror of
https://github.com/mikefarah/yq.git
synced 2025-03-15 16:37:46 +00:00
fixed tests
This commit is contained in:
parent
bb0e6fb857
commit
d80054dcc6
@ -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
|
||||||
|
@ -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",
|
||||||
|
Loading…
Reference in New Issue
Block a user