github.com/sleungcy-sap/cli@v7.1.0+incompatible/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("description", ServiceOffering{Description: "once upon a time"}, `{"description": "once upon a time"}`), 24 Entry( 25 "service broker guid", 26 ServiceOffering{ServiceBrokerGUID: "fake-service-broker-guid"}, 27 `{ 28 "relationships": { 29 "service_broker": { 30 "data": { 31 "guid": "fake-service-broker-guid" 32 } 33 } 34 } 35 }`, 36 ), 37 Entry( 38 "metadata", 39 ServiceOffering{ 40 Metadata: &Metadata{ 41 Labels: map[string]types.NullString{ 42 "foo": types.NewNullString("bar"), 43 "baz": types.NewNullString(), 44 }, 45 }, 46 }, 47 `{ 48 "metadata": { 49 "labels": { 50 "foo": "bar", 51 "baz": null 52 } 53 } 54 }`, 55 ), 56 Entry( 57 "everything", 58 ServiceOffering{ 59 Name: "fake-name", 60 GUID: "fake-guid", 61 Description: "once upon a time", 62 ServiceBrokerGUID: "fake-service-broker-guid", 63 Metadata: &Metadata{ 64 Labels: map[string]types.NullString{ 65 "foo": types.NewNullString("bar"), 66 "baz": types.NewNullString(), 67 }, 68 }, 69 }, 70 `{ 71 "name": "fake-name", 72 "guid": "fake-guid", 73 "url": "https://fake-url.com", 74 "description": "once upon a time", 75 "metadata": { 76 "labels": { 77 "foo": "bar", 78 "baz": null 79 } 80 }, 81 "relationships": { 82 "service_broker": { 83 "data": { 84 "guid": "fake-service-broker-guid" 85 } 86 } 87 } 88 }`, 89 ), 90 ) 91 })