MCPcopy Create free account
hub / github.com/devspace-sh/devspace / TestAddOperation

Function TestAddOperation

pkg/devspace/config/loader/patch/operation_test.go:19–266  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17}
18
19func TestAddOperation(t *testing.T) {
20 testCases := map[string]*operationTestCase{
21 "adding an element to an object": {
22 input: "foo: bar",
23 operation: &Operation{
24 Op: opAdd,
25 Path: ".baz",
26 Value: loadYamlFromString(`qux`),
27 },
28 expected: `
29 foo: bar
30 baz: qux
31 `,
32 },
33 "adding an element to an array": {
34 input: "foo: [bar,baz]",
35 operation: &Operation{
36 Op: opAdd,
37 Path: ".foo[1]",
38 Value: loadYamlFromString(`qux`),
39 },
40 expected: "foo: [bar,qux,baz]",
41 },
42 "adding an object to an object": {
43 input: `
44 foo: bar
45 `,
46 operation: &Operation{
47 Op: opAdd,
48 Path: ".child",
49 Value: loadYamlFromString(`
50 grandchild: {}
51 `),
52 },
53 expected: `
54 foo: bar
55 child:
56 grandchild: {}
57 `,
58 },
59 "appending an element to an array": {
60 input: `foo: [bar]`,
61 operation: &Operation{
62 Op: opAdd,
63 Path: ".foo",
64 Value: loadYamlFromString(`[abc,def]`),
65 },
66 expected: `foo: [bar, [abc, def]]`,
67 },
68 "adding a nil element to an object": {
69 input: `
70 foo: bar
71 `,
72 operation: &Operation{
73 Op: opAdd,
74 Path: ".baz",
75 Value: loadYamlFromString(`~`),
76 },

Callers

nothing calls this directly

Calls 2

loadYamlFromStringFunction · 0.85
runTestCasesFunction · 0.85

Tested by

no test coverage detected