github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/cf/api/resources/quotas_test.go (about) 1 package resources_test 2 3 import ( 4 . "code.cloudfoundry.org/cli/cf/api/resources" 5 6 "code.cloudfoundry.org/cli/cf/models" 7 "encoding/json" 8 . "github.com/onsi/ginkgo" 9 . "github.com/onsi/gomega" 10 ) 11 12 var _ = Describe("Quotas", func() { 13 Describe("ToFields", func() { 14 var resource QuotaResource 15 16 BeforeEach(func() { 17 resource = QuotaResource{ 18 Resource: Resource{ 19 Metadata: Metadata{ 20 GUID: "my-guid", 21 URL: "url.com", 22 }, 23 }, 24 Entity: models.QuotaResponse{ 25 GUID: "my-guid", 26 Name: "my-name", 27 MemoryLimit: 1024, 28 InstanceMemoryLimit: 5, 29 RoutesLimit: 10, 30 ServicesLimit: 5, 31 NonBasicServicesAllowed: true, 32 AppInstanceLimit: "10", 33 }, 34 } 35 }) 36 37 Describe("ReservedRoutePorts", func() { 38 Context("when it is provided by the API", func() { 39 BeforeEach(func() { 40 resource.Entity.ReservedRoutePorts = "5" 41 }) 42 43 It("returns back the value", func() { 44 fields := resource.ToFields() 45 Expect(fields.ReservedRoutePorts).To(Equal(json.Number("5"))) 46 }) 47 }) 48 49 Context("when it is *not* provided by the API", func() { 50 It("should be empty", func() { 51 fields := resource.ToFields() 52 Expect(fields.ReservedRoutePorts).To(BeEmpty()) 53 }) 54 }) 55 }) 56 }) 57 })