summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDave Henderson <dhenderson@gmail.com>2020-05-04 22:11:23 -0400
committerDave Henderson <dhenderson@gmail.com>2020-05-04 22:20:58 -0400
commit3ca4f8944e4f4ea43c53f1fed074e4199f04074d (patch)
tree5b091e0579a7fc3773d39d065c53dd3e16822610 /tests
parent8f6ec3d319569029b7f81d4c1eca4c359328d177 (diff)
New functions coll.Pick and coll.Omit
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/collection_test.go12
1 files changed, 12 insertions, 0 deletions
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]"})
+}