MCPcopy
hub / github.com/cloudfoundry/cli / CheckExpectedLabels

Function CheckExpectedLabels

integration/helpers/metadata.go:12–40  ·  view source on GitHub ↗
(url string, list bool, expected MetadataLabels)

Source from the content-addressed store, hash-verified

10type MetadataLabels map[string]string
11
12func CheckExpectedLabels(url string, list bool, expected MetadataLabels) {
13 type commonResource struct {
14 Metadata struct {
15 Labels MetadataLabels
16 }
17 }
18
19 session := CF("curl", url)
20 Eventually(session).Should(Exit(0))
21 resourceJSON := session.Out.Contents()
22 var resource commonResource
23
24 if list {
25 var resourceList struct {
26 Resources []commonResource
27 }
28
29 Expect(json.Unmarshal(resourceJSON, &resourceList)).To(Succeed())
30 Expect(resourceList.Resources).To(HaveLen(1))
31 resource = resourceList.Resources[0]
32 } else {
33 Expect(json.Unmarshal(resourceJSON, &resource)).To(Succeed())
34 }
35
36 Expect(resource.Metadata.Labels).To(HaveLen(len(expected)))
37 for k, v := range expected {
38 Expect(resource.Metadata.Labels).To(HaveKeyWithValue(k, v))
39 }
40}

Calls 1

CFFunction · 0.85

Tested by

no test coverage detected