Skip to content

Commit 4a1e756

Browse files
committed
add test op integration test
1 parent a347389 commit 4a1e756

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

patch/integration_test.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ instance_groups:
4747
username: user
4848
password: pass
4949
50+
- type: test
51+
path: /instance_groups/name=uaa/instances-not
52+
absent: true
53+
54+
# check current value
55+
- type: test
56+
path: /instance_groups/name=uaa/instances
57+
value: 0
58+
5059
- type: replace
5160
path: /instance_groups/name=uaa/instances
5261
value: 1
@@ -57,6 +66,13 @@ instance_groups:
5766
name: uaadb
5867
instances: 2
5968
69+
# check what was appended above
70+
- type: test
71+
path: /instance_groups/3
72+
value:
73+
name: uaadb
74+
instances: 2
75+
6076
- type: replace
6177
path: /instance_groups/name=cloud_controller:before
6278
value:
@@ -226,4 +242,35 @@ releases:
226242
Expect(err.Error()).To(Equal(
227243
"Error 'Custom error message': Expected to find a map key 'not-there' for path '/releases/0/not-there' (found map keys: 'name', 'version')"))
228244
})
245+
246+
It("shows test error messages", func() {
247+
inStr := `
248+
releases:
249+
- name: capi
250+
version: 0.1
251+
`
252+
253+
var in interface{}
254+
255+
err := yaml.Unmarshal([]byte(inStr), &in)
256+
Expect(err).ToNot(HaveOccurred())
257+
258+
opsStr := `
259+
- type: test
260+
path: /releases/0
261+
absent: true
262+
`
263+
264+
var opDefs []OpDefinition
265+
266+
err = yaml.Unmarshal([]byte(opsStr), &opDefs)
267+
Expect(err).ToNot(HaveOccurred())
268+
269+
ops, err := NewOpsFromDefinitions(opDefs)
270+
Expect(err).ToNot(HaveOccurred())
271+
272+
_, err = ops.Apply(in)
273+
Expect(err).To(HaveOccurred())
274+
Expect(err.Error()).To(Equal("Expected to not find '/releases/0'"))
275+
})
229276
})

0 commit comments

Comments
 (0)