github.com/wanddynosios/cli/v8@v8.7.9-0.20240221182337-1a92e3a7017f/resources/service_offering_resource_test.go (about) 1 package resources_test 2 3 import ( 4 "encoding/json" 5 6 . "code.cloudfoundry.org/cli/resources" 7 "code.cloudfoundry.org/cli/types" 8 . "github.com/onsi/ginkgo" 9 . "github.com/onsi/ginkgo/extensions/table" 10 . "github.com/onsi/gomega" 11 ) 12 13 var _ = Describe("service offering resource", func() { 14 DescribeTable( 15 "Unmarshaling", 16 func(serviceInstance ServiceOffering, serialized string) { 17 var parsed ServiceOffering 18 Expect(json.Unmarshal([]byte(serialized), &parsed)).NotTo(HaveOccurred()) 19 Expect(parsed).To(Equal(serviceInstance)) 20 }, 21 Entry("name", ServiceOffering{Name: "fake-name"}, `{"name": "fake-name"}`), 22 Entry("guid", ServiceOffering{GUID: "fake-guid"}, `{"guid": "fake-guid"}`), 23 Entry("shareable", ServiceOffering{AllowsInstanceSharing: true}, `{"shareable": true}`), 24 Entry("description", ServiceOffering{Description: "once upon a time"}, `{"description": "once upon a time"}`), 25 Entry("documentation_url", ServiceOffering{DocumentationURL: "https://docs.com"}, `{"documentation_url": "https://docs.com"}`), 26 Entry("tags", ServiceOffering{Tags: types.NewOptionalStringSlice("foo", "bar")}, `{"tags": ["foo", "bar"]}`), 27 Entry("tags empty", ServiceOffering{Tags: types.NewOptionalStringSlice()}, `{"tags": []}`), 28 Entry( 29 "service broker guid", 30 ServiceOffering{ServiceBrokerGUID: "fake-service-broker-guid"}, 31 `{ 32 "relationships": { 33 "service_broker": { 34 "data": { 35 "guid": "fake-service-broker-guid" 36 } 37 } 38 } 39 }`, 40 ), 41 Entry( 42 "metadata", 43 ServiceOffering{ 44 Metadata: &Metadata{ 45 Labels: map[string]types.NullString{ 46 "foo": types.NewNullString("bar"), 47 "baz": types.NewNullString(), 48 }, 49 }, 50 }, 51 `{ 52 "metadata": { 53 "labels": { 54 "foo": "bar", 55 "baz": null 56 } 57 } 58 }`, 59 ), 60 Entry( 61 "everything", 62 ServiceOffering{ 63 Name: "fake-name", 64 GUID: "fake-guid", 65 Description: "once upon a time", 66 DocumentationURL: "https://docs.com", 67 ServiceBrokerGUID: "fake-service-broker-guid", 68 Metadata: &Metadata{ 69 Labels: map[string]types.NullString{ 70 "foo": types.NewNullString("bar"), 71 "baz": types.NewNullString(), 72 }, 73 }, 74 }, 75 `{ 76 "name": "fake-name", 77 "guid": "fake-guid", 78 "url": "https://fake-url.com", 79 "description": "once upon a time", 80 "documentation_url": "https://docs.com", 81 "metadata": { 82 "labels": { 83 "foo": "bar", 84 "baz": null 85 } 86 }, 87 "relationships": { 88 "service_broker": { 89 "data": { 90 "guid": "fake-service-broker-guid" 91 } 92 } 93 } 94 }`, 95 ), 96 ) 97 })