From 3ca4f8944e4f4ea43c53f1fed074e4199f04074d Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Mon, 4 May 2020 22:11:23 -0400 Subject: New functions coll.Pick and coll.Omit Signed-off-by: Dave Henderson --- tests/integration/collection_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests') diff --git a/tests/integration/collection_test.go b/tests/integration/collection_test.go index f593777a..f21adcc1 100644 --- a/tests/integration/collection_test.go +++ b/tests/integration/collection_test.go @@ -118,3 +118,15 @@ func (s *CollSuite) TestFlatten(c *C) { "-i", "{{ `"+in+"` | jsonArray | coll.Flatten 2 | toJSON }}")) result.Assert(c, icmd.Expected{ExitCode: 0, Out: "[1,2,3,4,[[5],6],7]"}) } + +func (s *CollSuite) TestPick(c *C) { + result := icmd.RunCmd(icmd.Command(GomplateBin, + "-i", `{{ $data := dict "foo" 1 "bar" 2 "baz" 3 }}{{ coll.Pick "foo" "baz" $data }}`)) + result.Assert(c, icmd.Expected{ExitCode: 0, Out: "map[baz:3 foo:1]"}) +} + +func (s *CollSuite) TestOmit(c *C) { + result := icmd.RunCmd(icmd.Command(GomplateBin, + "-i", `{{ $data := dict "foo" 1 "bar" 2 "baz" 3 }}{{ coll.Omit "foo" "baz" $data }}`)) + result.Assert(c, icmd.Expected{ExitCode: 0, Out: "map[bar:2]"}) +} -- cgit v1.2.3