From d80054dcc6d479745dd87796c821d1434253ffd9 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Tue, 30 Nov 2021 13:16:35 +1100 Subject: [PATCH] fixed tests --- pkg/yqlib/doc/entries.md | 9 +-------- pkg/yqlib/operator_entries_test.go | 10 +++++++++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/pkg/yqlib/doc/entries.md b/pkg/yqlib/doc/entries.md index e1814418..95fae132 100644 --- a/pkg/yqlib/doc/entries.md +++ b/pkg/yqlib/doc/entries.md @@ -91,21 +91,14 @@ Given a sample.yml file of: a: 1 b: 2 ``` -And another sample another.yml file of: -```yaml -c: 1 -d: 2 -``` then ```bash -yq eval-all 'with_entries(.key |= "KEY_" + .)' sample.yml another.yml +yq eval 'with_entries(.key |= "KEY_" + .)' sample.yml ``` will output ```yaml KEY_a: 1 KEY_b: 2 -KEY_c: 1 -KEY_d: 2 ``` ## Use with_entries to filter the map diff --git a/pkg/yqlib/operator_entries_test.go b/pkg/yqlib/operator_entries_test.go index bedc8e41..4bee227d 100644 --- a/pkg/yqlib/operator_entries_test.go +++ b/pkg/yqlib/operator_entries_test.go @@ -47,8 +47,16 @@ var entriesOperatorScenarios = []expressionScenario{ { description: "Use with_entries to update keys", document: `{a: 1, b: 2}`, - document2: `{c: 1, d: 2}`, 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{ "D0, P[], (!!map)::KEY_a: 1\nKEY_b: 2\n", "D0, P[], (!!map)::KEY_c: 1\nKEY_d: 2\n",