github.com/IBM-Cloud/bluemix-go@v0.0.0-20240423071914-9e96525baef4/api/resource/resourcev1/management/resource_quota_test.go (about)

     1  package management
     2  
     3  import (
     4  	"log"
     5  	"net/http"
     6  
     7  	"github.com/IBM-Cloud/bluemix-go"
     8  
     9  	"github.com/IBM-Cloud/bluemix-go/client"
    10  	"github.com/IBM-Cloud/bluemix-go/session"
    11  	"github.com/onsi/gomega/ghttp"
    12  
    13  	. "github.com/onsi/ginkgo"
    14  	. "github.com/onsi/gomega"
    15  )
    16  
    17  var _ = Describe("QuotaDefinitions", func() {
    18  	var server *ghttp.Server
    19  	AfterEach(func() {
    20  		server.Close()
    21  	})
    22  
    23  	Describe("List()", func() {
    24  		Context("When there are multiple quota definitions", func() {
    25  			BeforeEach(func() {
    26  				server = ghttp.NewServer()
    27  				server.AppendHandlers(
    28  					ghttp.CombineHandlers(
    29  						ghttp.VerifyRequest(http.MethodGet, "/v1/quota_definitions"),
    30  						ghttp.RespondWith(http.StatusOK, `{
    31  							"resources":[{
    32  								"_id": "7ce89f4a-4381-4600-b814-3cd9a4f4bdf4",
    33  								"_rev": "1-58b5e60b5bc8736565866f37bd413c1e",
    34  								"name": "Trial Quota",
    35  								"type": "SDQ",
    36  								"number_of_service_instances": 3,
    37  								"number_of_apps": 4,
    38  								"instances_per_app": 4,
    39  								"instance_memory": "1G",
    40  								"total_app_memory": "1G",
    41  								"vsi_limit": 1,
    42  								"service_quotas": [
    43  									{
    44  										"_id": "65012f5b6fa84ecaaac5eab4abc2d0fd",
    45  										"service_id": "rcf0c17db8-35ad-11e7-a919-92ebcb67fe33",
    46  										"limit": 1
    47  									},
    48  									{
    49  										"_id": "8b35eb93b6b14f50b6c4f3ff0dfd0358",
    50  										"service_id": "rcd1a5a758-03a1-11e7-93ae-92361f002671",
    51  										"limit": 1
    52  									}
    53  								],
    54  								"created_at": "2017-05-16T17:12:52.925Z",
    55  								"updated_at": "2017-05-16T17:12:52.925Z"
    56  							},
    57  							{
    58  								"_id": "a3d7b8d01e261c24677937c29ab33f3c",
    59  								"_rev": "1-cbdbf21c8f06da0ae8961e4abfd279e6",
    60  								"name": "Pay-as-you-go Quota",
    61  								"type": "SDQ",
    62  								"number_of_service_instances": 3,
    63  								"number_of_apps": 100,
    64  								"instances_per_app": 32,
    65  								"instance_memory": "512G",
    66  								"total_app_memory": "512G",
    67  								"vsi_limit": 100,
    68  								"service_quotas": [],
    69  								"created_at": "2017-05-16T17:12:52.925Z",
    70  								"updated_at": "2017-05-16T17:12:52.925Z"
    71  							}
    72  						]}`),
    73  					),
    74  				)
    75  			})
    76  			It("should return all of them", func() {
    77  				definitions, err := newTestQuotaDefinitionRepo(server.URL()).List()
    78  
    79  				Expect(err).ShouldNot(HaveOccurred())
    80  				Expect(definitions).Should(HaveLen(2))
    81  
    82  				definition := definitions[0]
    83  				Expect(definition.ID).Should(Equal("7ce89f4a-4381-4600-b814-3cd9a4f4bdf4"))
    84  				Expect(definition.Revision).Should(Equal("1-58b5e60b5bc8736565866f37bd413c1e"))
    85  				Expect(definition.Name).Should(Equal("Trial Quota"))
    86  				Expect(definition.Type).Should(Equal("SDQ"))
    87  				Expect(definition.ServiceInstanceCountLimit).Should(Equal(3))
    88  				Expect(definition.AppCountLimit).Should(Equal(4))
    89  				Expect(definition.AppInstanceCountLimit).Should(Equal(4))
    90  				Expect(definition.AppInstanceMemoryLimit).Should(Equal("1G"))
    91  				Expect(definition.TotalAppMemoryLimit).Should(Equal("1G"))
    92  				Expect(definition.VSICountLimit).Should(Equal(1))
    93  				Expect(definition.ServiceQuotas).Should(HaveLen(2))
    94  				Expect(definition.CreatedAt).Should(Equal("2017-05-16T17:12:52.925Z"))
    95  				Expect(definition.UpdatedAt).Should(Equal("2017-05-16T17:12:52.925Z"))
    96  				serviceQuota := definition.ServiceQuotas[0]
    97  				Expect(serviceQuota.ID).Should(Equal("65012f5b6fa84ecaaac5eab4abc2d0fd"))
    98  				Expect(serviceQuota.ServiceID).Should(Equal("rcf0c17db8-35ad-11e7-a919-92ebcb67fe33"))
    99  				Expect(serviceQuota.Limit).Should(Equal(1))
   100  				serviceQuota = definition.ServiceQuotas[1]
   101  				Expect(serviceQuota.ID).Should(Equal("8b35eb93b6b14f50b6c4f3ff0dfd0358"))
   102  				Expect(serviceQuota.ServiceID).Should(Equal("rcd1a5a758-03a1-11e7-93ae-92361f002671"))
   103  				Expect(serviceQuota.Limit).Should(Equal(1))
   104  
   105  				definition = definitions[1]
   106  				Expect(definition.ID).Should(Equal("a3d7b8d01e261c24677937c29ab33f3c"))
   107  				Expect(definition.Revision).Should(Equal("1-cbdbf21c8f06da0ae8961e4abfd279e6"))
   108  				Expect(definition.Name).Should(Equal("Pay-as-you-go Quota"))
   109  				Expect(definition.Type).Should(Equal("SDQ"))
   110  				Expect(definition.ServiceInstanceCountLimit).Should(Equal(3))
   111  				Expect(definition.AppCountLimit).Should(Equal(100))
   112  				Expect(definition.AppInstanceCountLimit).Should(Equal(32))
   113  				Expect(definition.AppInstanceMemoryLimit).Should(Equal("512G"))
   114  				Expect(definition.TotalAppMemoryLimit).Should(Equal("512G"))
   115  				Expect(definition.VSICountLimit).Should(Equal(100))
   116  				Expect(definition.ServiceQuotas).Should(BeEmpty())
   117  				Expect(definition.CreatedAt).Should(Equal("2017-05-16T17:12:52.925Z"))
   118  				Expect(definition.UpdatedAt).Should(Equal("2017-05-16T17:12:52.925Z"))
   119  			})
   120  		})
   121  
   122  		Context("When there is one quota definition", func() {
   123  			BeforeEach(func() {
   124  				server = ghttp.NewServer()
   125  				server.AppendHandlers(
   126  					ghttp.CombineHandlers(
   127  						ghttp.VerifyRequest(http.MethodGet, "/v1/quota_definitions"),
   128  						ghttp.RespondWith(http.StatusOK, `{
   129  							"resources":[{
   130  								"_id": "a3d7b8d01e261c24677937c29ab33f3c",
   131  								"_rev": "1-cbdbf21c8f06da0ae8961e4abfd279e6",
   132  								"name": "Pay-as-you-go Quota",
   133  								"type": "SDQ",
   134  								"number_of_service_instances": 3,
   135  								"number_of_apps": 100,
   136  								"instances_per_app": 32,
   137  								"instance_memory": "512G",
   138  								"total_app_memory": "512G",
   139  								"vsi_limit": 100,
   140  								"service_quotas": [],
   141  								"created_at": "2017-05-16T17:12:52.925Z",
   142  								"updated_at": "2017-05-16T17:12:52.925Z"
   143  							}
   144  						]}`),
   145  					),
   146  				)
   147  			})
   148  			It("should return the only one", func() {
   149  				definitions, err := newTestQuotaDefinitionRepo(server.URL()).List()
   150  
   151  				Expect(err).ShouldNot(HaveOccurred())
   152  				Expect(definitions).Should(HaveLen(1))
   153  
   154  				definition := definitions[0]
   155  				Expect(definition.ID).Should(Equal("a3d7b8d01e261c24677937c29ab33f3c"))
   156  				Expect(definition.Revision).Should(Equal("1-cbdbf21c8f06da0ae8961e4abfd279e6"))
   157  				Expect(definition.Name).Should(Equal("Pay-as-you-go Quota"))
   158  				Expect(definition.Type).Should(Equal("SDQ"))
   159  				Expect(definition.ServiceInstanceCountLimit).Should(Equal(3))
   160  				Expect(definition.AppCountLimit).Should(Equal(100))
   161  				Expect(definition.AppInstanceCountLimit).Should(Equal(32))
   162  				Expect(definition.AppInstanceMemoryLimit).Should(Equal("512G"))
   163  				Expect(definition.TotalAppMemoryLimit).Should(Equal("512G"))
   164  				Expect(definition.VSICountLimit).Should(Equal(100))
   165  				Expect(definition.ServiceQuotas).Should(BeEmpty())
   166  				Expect(definition.CreatedAt).Should(Equal("2017-05-16T17:12:52.925Z"))
   167  				Expect(definition.UpdatedAt).Should(Equal("2017-05-16T17:12:52.925Z"))
   168  			})
   169  		})
   170  
   171  		Context("When there is no quota definition", func() {
   172  			BeforeEach(func() {
   173  				server = ghttp.NewServer()
   174  				server.AppendHandlers(
   175  					ghttp.CombineHandlers(
   176  						ghttp.VerifyRequest(http.MethodGet, "/v1/quota_definitions"),
   177  						ghttp.RespondWith(http.StatusOK, `{"resources":[]}`),
   178  					),
   179  				)
   180  			})
   181  			It("should return empty", func() {
   182  				definitions, err := newTestQuotaDefinitionRepo(server.URL()).List()
   183  
   184  				Expect(err).ShouldNot(HaveOccurred())
   185  				Expect(definitions).Should(BeEmpty())
   186  			})
   187  		})
   188  
   189  		Context("When there is backend error", func() {
   190  			BeforeEach(func() {
   191  				server = ghttp.NewServer()
   192  				server.AppendHandlers(
   193  					ghttp.CombineHandlers(
   194  						ghttp.VerifyRequest(http.MethodGet, "/v1/quota_definitions"),
   195  						ghttp.RespondWith(http.StatusUnauthorized, `{"Message":"Invalid Authorization"}`),
   196  					),
   197  				)
   198  			})
   199  			It("should return error", func() {
   200  				definitions, err := newTestQuotaDefinitionRepo(server.URL()).List()
   201  
   202  				Expect(err).Should(HaveOccurred())
   203  				Expect(definitions).Should(BeEmpty())
   204  			})
   205  		})
   206  	})
   207  
   208  	Describe("FindByName()", func() {
   209  		Context("When there are multiple quota definitions having the same name", func() {
   210  			BeforeEach(func() {
   211  				server = ghttp.NewServer()
   212  				server.AppendHandlers(
   213  					ghttp.CombineHandlers(
   214  						ghttp.VerifyRequest(http.MethodGet, "/v1/quota_definitions"),
   215  						ghttp.RespondWith(http.StatusOK, `{
   216  							"resources":[{
   217  								"_id": "7ce89f4a-4381-4600-b814-3cd9a4f4bdf4",
   218  								"_rev": "1-58b5e60b5bc8736565866f37bd413c1e",
   219  								"name": "Trial-Quota",
   220  								"type": "SDQ",
   221  								"number_of_service_instances": 3,
   222  								"number_of_apps": 4,
   223  								"instances_per_app": 4,
   224  								"instance_memory": "1G",
   225  								"total_app_memory": "1G",
   226  								"vsi_limit": 1,
   227  								"service_quotas": [
   228  									{
   229  										"_id": "65012f5b6fa84ecaaac5eab4abc2d0fd",
   230  										"service_id": "rcf0c17db8-35ad-11e7-a919-92ebcb67fe33",
   231  										"limit": 1
   232  									},
   233  									{
   234  										"_id": "8b35eb93b6b14f50b6c4f3ff0dfd0358",
   235  										"service_id": "rcd1a5a758-03a1-11e7-93ae-92361f002671",
   236  										"limit": 1
   237  									}
   238  								],
   239  								"created_at": "2017-05-16T17:12:52.925Z",
   240  								"updated_at": "2017-05-16T17:12:52.925Z"
   241  							},
   242  							{
   243  								"_id": "a3d7b8d01e261c24677937c29ab33f3c",
   244  								"_rev": "1-cbdbf21c8f06da0ae8961e4abfd279e6",
   245  								"name": "Trial-Quota",
   246  								"type": "SDQ",
   247  								"number_of_service_instances": 3,
   248  								"number_of_apps": 100,
   249  								"instances_per_app": 32,
   250  								"instance_memory": "512G",
   251  								"total_app_memory": "512G",
   252  								"vsi_limit": 100,
   253  								"service_quotas": [],
   254  								"created_at": "2017-05-16T17:12:52.925Z",
   255  								"updated_at": "2017-05-16T17:12:52.925Z"
   256  							}
   257  						]}`),
   258  					),
   259  				)
   260  			})
   261  			It("should return all of them", func() {
   262  				definitions, err := newTestQuotaDefinitionRepo(server.URL()).FindByName("Trial-Quota")
   263  
   264  				Expect(err).ShouldNot(HaveOccurred())
   265  				Expect(definitions).Should(HaveLen(2))
   266  
   267  				definition := definitions[0]
   268  				Expect(definition.ID).Should(Equal("7ce89f4a-4381-4600-b814-3cd9a4f4bdf4"))
   269  				Expect(definition.Revision).Should(Equal("1-58b5e60b5bc8736565866f37bd413c1e"))
   270  				Expect(definition.Name).Should(Equal("Trial-Quota"))
   271  				Expect(definition.Type).Should(Equal("SDQ"))
   272  				Expect(definition.ServiceInstanceCountLimit).Should(Equal(3))
   273  				Expect(definition.AppCountLimit).Should(Equal(4))
   274  				Expect(definition.AppInstanceCountLimit).Should(Equal(4))
   275  				Expect(definition.AppInstanceMemoryLimit).Should(Equal("1G"))
   276  				Expect(definition.TotalAppMemoryLimit).Should(Equal("1G"))
   277  				Expect(definition.VSICountLimit).Should(Equal(1))
   278  				Expect(definition.ServiceQuotas).Should(HaveLen(2))
   279  				Expect(definition.CreatedAt).Should(Equal("2017-05-16T17:12:52.925Z"))
   280  				Expect(definition.UpdatedAt).Should(Equal("2017-05-16T17:12:52.925Z"))
   281  				serviceQuota := definition.ServiceQuotas[0]
   282  				Expect(serviceQuota.ID).Should(Equal("65012f5b6fa84ecaaac5eab4abc2d0fd"))
   283  				Expect(serviceQuota.ServiceID).Should(Equal("rcf0c17db8-35ad-11e7-a919-92ebcb67fe33"))
   284  				Expect(serviceQuota.Limit).Should(Equal(1))
   285  				serviceQuota = definition.ServiceQuotas[1]
   286  				Expect(serviceQuota.ID).Should(Equal("8b35eb93b6b14f50b6c4f3ff0dfd0358"))
   287  				Expect(serviceQuota.ServiceID).Should(Equal("rcd1a5a758-03a1-11e7-93ae-92361f002671"))
   288  				Expect(serviceQuota.Limit).Should(Equal(1))
   289  
   290  				definition = definitions[1]
   291  				Expect(definition.ID).Should(Equal("a3d7b8d01e261c24677937c29ab33f3c"))
   292  				Expect(definition.Revision).Should(Equal("1-cbdbf21c8f06da0ae8961e4abfd279e6"))
   293  				Expect(definition.Name).Should(Equal("Trial-Quota"))
   294  				Expect(definition.Type).Should(Equal("SDQ"))
   295  				Expect(definition.ServiceInstanceCountLimit).Should(Equal(3))
   296  				Expect(definition.AppCountLimit).Should(Equal(100))
   297  				Expect(definition.AppInstanceCountLimit).Should(Equal(32))
   298  				Expect(definition.AppInstanceMemoryLimit).Should(Equal("512G"))
   299  				Expect(definition.TotalAppMemoryLimit).Should(Equal("512G"))
   300  				Expect(definition.VSICountLimit).Should(Equal(100))
   301  				Expect(definition.ServiceQuotas).Should(BeEmpty())
   302  				Expect(definition.CreatedAt).Should(Equal("2017-05-16T17:12:52.925Z"))
   303  				Expect(definition.UpdatedAt).Should(Equal("2017-05-16T17:12:52.925Z"))
   304  			})
   305  		})
   306  
   307  		Context("When there is one quota definition having the name", func() {
   308  			BeforeEach(func() {
   309  				server = ghttp.NewServer()
   310  				server.AppendHandlers(
   311  					ghttp.CombineHandlers(
   312  						ghttp.VerifyRequest(http.MethodGet, "/v1/quota_definitions"),
   313  						ghttp.RespondWith(http.StatusOK, `{
   314  							"resources":[{
   315  								"_id": "7ce89f4a-4381-4600-b814-3cd9a4f4bdf4",
   316  								"_rev": "1-58b5e60b5bc8736565866f37bd413c1e",
   317  								"name": "Trial Quota",
   318  								"type": "SDQ",
   319  								"number_of_service_instances": 3,
   320  								"number_of_apps": 4,
   321  								"instances_per_app": 4,
   322  								"instance_memory": "1G",
   323  								"total_app_memory": "1G",
   324  								"vsi_limit": 1,
   325  								"service_quotas": [
   326  									{
   327  										"_id": "65012f5b6fa84ecaaac5eab4abc2d0fd",
   328  										"service_id": "rcf0c17db8-35ad-11e7-a919-92ebcb67fe33",
   329  										"limit": 1
   330  									},
   331  									{
   332  										"_id": "8b35eb93b6b14f50b6c4f3ff0dfd0358",
   333  										"service_id": "rcd1a5a758-03a1-11e7-93ae-92361f002671",
   334  										"limit": 1
   335  									}
   336  								],
   337  								"created_at": "2017-05-16T17:12:52.925Z",
   338  								"updated_at": "2017-05-16T17:12:52.925Z"
   339  							},
   340  							{
   341  								"_id": "a3d7b8d01e261c24677937c29ab33f3c",
   342  								"_rev": "1-cbdbf21c8f06da0ae8961e4abfd279e6",
   343  								"name": "Pay-as-you-go Quota",
   344  								"type": "SDQ",
   345  								"number_of_service_instances": 3,
   346  								"number_of_apps": 100,
   347  								"instances_per_app": 32,
   348  								"instance_memory": "512G",
   349  								"total_app_memory": "512G",
   350  								"vsi_limit": 100,
   351  								"service_quotas": [],
   352  								"created_at": "2017-05-16T17:12:52.925Z",
   353  								"updated_at": "2017-05-16T17:12:52.925Z"
   354  							}
   355  						]}`),
   356  					),
   357  				)
   358  			})
   359  			It("should return the only one", func() {
   360  				definitions, err := newTestQuotaDefinitionRepo(server.URL()).FindByName("Pay-as-you-go Quota")
   361  
   362  				Expect(err).ShouldNot(HaveOccurred())
   363  				Expect(definitions).Should(HaveLen(1))
   364  
   365  				definition := definitions[0]
   366  				Expect(definition.ID).Should(Equal("a3d7b8d01e261c24677937c29ab33f3c"))
   367  				Expect(definition.Revision).Should(Equal("1-cbdbf21c8f06da0ae8961e4abfd279e6"))
   368  				Expect(definition.Name).Should(Equal("Pay-as-you-go Quota"))
   369  				Expect(definition.Type).Should(Equal("SDQ"))
   370  				Expect(definition.ServiceInstanceCountLimit).Should(Equal(3))
   371  				Expect(definition.AppCountLimit).Should(Equal(100))
   372  				Expect(definition.AppInstanceCountLimit).Should(Equal(32))
   373  				Expect(definition.AppInstanceMemoryLimit).Should(Equal("512G"))
   374  				Expect(definition.TotalAppMemoryLimit).Should(Equal("512G"))
   375  				Expect(definition.VSICountLimit).Should(Equal(100))
   376  				Expect(definition.ServiceQuotas).Should(BeEmpty())
   377  				Expect(definition.CreatedAt).Should(Equal("2017-05-16T17:12:52.925Z"))
   378  				Expect(definition.UpdatedAt).Should(Equal("2017-05-16T17:12:52.925Z"))
   379  			})
   380  		})
   381  
   382  		Context("When there is no quota definition having the same name", func() {
   383  			BeforeEach(func() {
   384  				server = ghttp.NewServer()
   385  				server.AppendHandlers(
   386  					ghttp.CombineHandlers(
   387  						ghttp.VerifyRequest(http.MethodGet, "/v1/quota_definitions"),
   388  						ghttp.RespondWith(http.StatusOK, `{"resources":[
   389  							{
   390  								"_id": "a3d7b8d01e261c24677937c29ab33f3c",
   391  								"_rev": "1-cbdbf21c8f06da0ae8961e4abfd279e6",
   392  								"name": "Pay-as-you-go Quota",
   393  								"type": "SDQ",
   394  								"number_of_service_instances": 3,
   395  								"number_of_apps": 100,
   396  								"instances_per_app": 32,
   397  								"instance_memory": "512G",
   398  								"total_app_memory": "512G",
   399  								"vsi_limit": 100,
   400  								"service_quotas": [],
   401  								"created_at": "2017-05-16T17:12:52.925Z",
   402  								"updated_at": "2017-05-16T17:12:52.925Z"
   403  							}
   404  						]}`),
   405  					),
   406  				)
   407  			})
   408  			It("should return empty", func() {
   409  				definitions, err := newTestQuotaDefinitionRepo(server.URL()).FindByName("abc")
   410  
   411  				Expect(err).Should(HaveOccurred())
   412  				Expect(definitions).Should(BeEmpty())
   413  			})
   414  		})
   415  
   416  		Context("When there is no quota definition returned", func() {
   417  			BeforeEach(func() {
   418  				server = ghttp.NewServer()
   419  				server.AppendHandlers(
   420  					ghttp.CombineHandlers(
   421  						ghttp.VerifyRequest(http.MethodGet, "/v1/quota_definitions"),
   422  						ghttp.RespondWith(http.StatusOK, `{"resources":[]}`),
   423  					),
   424  				)
   425  			})
   426  			It("should return empty", func() {
   427  				definitions, err := newTestQuotaDefinitionRepo(server.URL()).FindByName("abc")
   428  
   429  				Expect(err).Should(HaveOccurred())
   430  				Expect(definitions).Should(BeEmpty())
   431  			})
   432  		})
   433  
   434  		Context("When there is backend error", func() {
   435  			BeforeEach(func() {
   436  				server = ghttp.NewServer()
   437  				server.AppendHandlers(
   438  					ghttp.CombineHandlers(
   439  						ghttp.VerifyRequest(http.MethodGet, "/v1/quota_definitions"),
   440  						ghttp.RespondWith(http.StatusUnauthorized, `{"Message":"Invalid Authorization"}`),
   441  					),
   442  				)
   443  			})
   444  			It("should return error", func() {
   445  				definitions, err := newTestQuotaDefinitionRepo(server.URL()).FindByName("test")
   446  
   447  				Expect(err).Should(HaveOccurred())
   448  				Expect(definitions).Should(BeEmpty())
   449  			})
   450  		})
   451  	})
   452  
   453  	Describe("Get()", func() {
   454  		Context("When the quota definition exists", func() {
   455  			BeforeEach(func() {
   456  				server = ghttp.NewServer()
   457  				server.AppendHandlers(
   458  					ghttp.CombineHandlers(
   459  						ghttp.VerifyRequest(http.MethodGet, "/v1/quota_definitions/a3d7b8d01e261c24677937c29ab33f3c"),
   460  						ghttp.RespondWith(http.StatusOK, `{
   461  							"name": "Pay-as-you-go Quota",
   462  							"type": "SDQ",
   463  							"number_of_service_instances": 3,
   464  							"number_of_apps": 100,
   465  							"instances_per_app": 32,
   466  							"instance_memory": "512G",
   467  							"total_app_memory": "512G",
   468  							"vsi_limit": 100,
   469  							"service_quotas": [
   470  								{
   471  									"_id": "65012f5b6fa84ecaaac5eab4abc2d0fd",
   472  									"service_id": "rcf0c17db8-35ad-11e7-a919-92ebcb67fe33",
   473  									"limit": 1
   474  								},
   475  								{
   476  									"_id": "8b35eb93b6b14f50b6c4f3ff0dfd0358",
   477  									"service_id": "rcd1a5a758-03a1-11e7-93ae-92361f002671",
   478  									"limit": 1
   479  								}
   480  							],
   481  							"created_at": "2017-05-16T17:12:52.925Z",
   482  							"updated_at": "2017-05-16T17:12:52.925Z",
   483  							"id": "a3d7b8d01e261c24677937c29ab33f3c"
   484  						}`),
   485  					),
   486  				)
   487  			})
   488  			It("should return the quota definition", func() {
   489  				quota, err := newTestQuotaDefinitionRepo(server.URL()).Get("a3d7b8d01e261c24677937c29ab33f3c")
   490  
   491  				Expect(err).ShouldNot(HaveOccurred())
   492  				Expect(quota).ShouldNot(BeNil())
   493  				// Bug in BSS: https://github.ibm.com/BSS/resource-manager/issues/15
   494  				//Expect(quota.ID).Should(Equal("a3d7b8d01e261c24677937c29ab33f3c"))
   495  				//Expect(quota.Revision).Should(Equal("1-cbdbf21c8f06da0ae8961e4abfd279e6"))
   496  				Expect(quota.Name).Should(Equal("Pay-as-you-go Quota"))
   497  				Expect(quota.Type).Should(Equal("SDQ"))
   498  				Expect(quota.ServiceInstanceCountLimit).Should(Equal(3))
   499  				Expect(quota.AppCountLimit).Should(Equal(100))
   500  				Expect(quota.AppInstanceCountLimit).Should(Equal(32))
   501  				Expect(quota.AppInstanceMemoryLimit).Should(Equal("512G"))
   502  				Expect(quota.TotalAppMemoryLimit).Should(Equal("512G"))
   503  				Expect(quota.VSICountLimit).Should(Equal(100))
   504  				Expect(quota.ServiceQuotas).Should(HaveLen(2))
   505  				serviceQuota := quota.ServiceQuotas[0]
   506  				Expect(serviceQuota.ID).Should(Equal("65012f5b6fa84ecaaac5eab4abc2d0fd"))
   507  				Expect(serviceQuota.ServiceID).Should(Equal("rcf0c17db8-35ad-11e7-a919-92ebcb67fe33"))
   508  				Expect(serviceQuota.Limit).Should(Equal(1))
   509  				serviceQuota = quota.ServiceQuotas[1]
   510  				Expect(serviceQuota.ID).Should(Equal("8b35eb93b6b14f50b6c4f3ff0dfd0358"))
   511  				Expect(serviceQuota.ServiceID).Should(Equal("rcd1a5a758-03a1-11e7-93ae-92361f002671"))
   512  				Expect(serviceQuota.Limit).Should(Equal(1))
   513  				Expect(quota.CreatedAt).Should(Equal("2017-05-16T17:12:52.925Z"))
   514  				Expect(quota.UpdatedAt).Should(Equal("2017-05-16T17:12:52.925Z"))
   515  			})
   516  		})
   517  
   518  		Context("When the quota definition do not exist", func() {
   519  			It("should return error", func() {
   520  
   521  			})
   522  		})
   523  
   524  		Context("When there is backend error", func() {
   525  			It("should return error", func() {
   526  
   527  			})
   528  		})
   529  	})
   530  })
   531  
   532  func newTestQuotaDefinitionRepo(url string) ResourceQuotaRepository {
   533  	sess, err := session.New()
   534  	if err != nil {
   535  		log.Fatal(err)
   536  	}
   537  	conf := sess.Config.Copy()
   538  	conf.Endpoint = &url
   539  
   540  	client := client.Client{
   541  		Config:      conf,
   542  		ServiceName: bluemix.ResourceManagementService,
   543  	}
   544  
   545  	return newResourceQuotaAPI(&client)
   546  }