github.com/cloudfoundry/cli@v7.1.0+incompatible/resources/service_plan_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 plan resource", func() { 14 DescribeTable( 15 "Unmarshaling", 16 func(servicePlan ServicePlan, serialized string) { 17 var parsed ServicePlan 18 Expect(json.Unmarshal([]byte(serialized), &parsed)).NotTo(HaveOccurred()) 19 Expect(parsed).To(Equal(servicePlan)) 20 }, 21 Entry( 22 "basic", 23 ServicePlan{ 24 GUID: "fake-service-plan-guid", 25 Name: "fake-service-plan-name", 26 ServiceOfferingGUID: "fake-service-offering-guid", 27 }, 28 `{ 29 "guid": "fake-service-plan-guid", 30 "name": "fake-service-plan-name", 31 "relationships": { 32 "service_offering": { 33 "data": { 34 "guid": "fake-service-offering-guid" 35 } 36 } 37 } 38 }`, 39 ), 40 Entry( 41 "detailed", 42 ServicePlan{ 43 GUID: "fake-service-plan-guid", 44 Name: "fake-service-plan-name", 45 ServiceOfferingGUID: "fake-service-offering-guid", 46 Description: "fake-description", 47 Available: true, 48 VisibilityType: "public", 49 Free: true, 50 Costs: []ServicePlanCost{ 51 { 52 Amount: 12.5, 53 Currency: "USD", 54 Unit: "month", 55 }, 56 { 57 Amount: 3.25, 58 Currency: "EUR", 59 Unit: "day", 60 }, 61 }, 62 SpaceGUID: "fake-space-guid", 63 Metadata: &Metadata{ 64 Labels: map[string]types.NullString{ 65 "foo": types.NewNullString("bar"), 66 "baz": types.NewNullString(), 67 }, 68 }, 69 }, 70 `{ 71 "guid": "fake-service-plan-guid", 72 "name": "fake-service-plan-name", 73 "description": "fake-description", 74 "available": true, 75 "visibility_type": "public", 76 "free": true, 77 "costs": [ 78 { 79 "amount": 12.5, 80 "currency": "USD", 81 "unit": "month" 82 }, 83 { 84 "amount": 3.25, 85 "currency": "EUR", 86 "unit": "day" 87 } 88 ], 89 "metadata": { 90 "labels": { 91 "foo": "bar", 92 "baz": null 93 } 94 }, 95 "relationships": { 96 "service_offering": { 97 "data": { 98 "guid": "fake-service-offering-guid" 99 } 100 }, 101 "space": { 102 "data": { 103 "guid": "fake-space-guid" 104 } 105 } 106 } 107 }`, 108 ), 109 ) 110 })