| 1 | package execution_test |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "github.com/tomwright/dasel/v3/model" |
| 7 | _ "github.com/tomwright/dasel/v3/parsing/json" |
| 8 | ) |
| 9 | |
| 10 | func TestFuncJoin(t *testing.T) { |
| 11 | t.Run("chained input", testCase{ |
| 12 | s: `["a","b","c"].join(",")`, |
| 13 | out: model.NewStringValue("a,b,c"), |
| 14 | }.run) |
| 15 | t.Run("vararg input", testCase{ |
| 16 | s: `join(",", "a", "b", "c")`, |
| 17 | out: model.NewStringValue("a,b,c"), |
| 18 | }.run) |
| 19 | t.Run("array input", testCase{ |
| 20 | s: `join(",", ["a", "b", "c"])`, |
| 21 | out: model.NewStringValue("a,b,c"), |
| 22 | }.run) |
| 23 | t.Run("array input newline", testCase{ |
| 24 | s: `join("\n", ["a", "b", "c"])`, |
| 25 | out: model.NewStringValue(`a |
| 26 | b |
| 27 | c`), |
| 28 | }.run) |
| 29 | } |