@@ -33,14 +33,14 @@ func TestValidateCapacity(t *testing.T) {
3333 name : "valid capacity value for GreaterThan operator" ,
3434 value : "10" ,
3535 operator : placementv1beta1 .PropertySelectorGreaterThan ,
36- wantValue : 10 ,
36+ wantValue : 11 ,
3737 wantError : false ,
3838 },
3939 {
4040 name : "valid capacity value for GreaterThanOrEqualTo operator" ,
4141 value : "50" ,
4242 operator : placementv1beta1 .PropertySelectorGreaterThanOrEqualTo ,
43- wantValue : 49 ,
43+ wantValue : 50 ,
4444 wantError : false ,
4545 },
4646 {
@@ -72,11 +72,11 @@ func TestValidateCapacity(t *testing.T) {
7272 errorSubstring : "invalid capacity value" ,
7373 },
7474 {
75- name : "unsupported operator for capacity of zero" ,
75+ name : "invalid value of zero for capacity " ,
7676 value : "0" ,
7777 operator : placementv1beta1 .PropertySelectorGreaterThanOrEqualTo ,
7878 wantError : true ,
79- errorSubstring : "capacity value cannot be zero for operator " ,
79+ errorSubstring : "is below minimum allowed value " ,
8080 },
8181 {
8282 name : "capacity equal to max limit with GreaterThan operator" ,
@@ -85,18 +85,11 @@ func TestValidateCapacity(t *testing.T) {
8585 wantError : true ,
8686 errorSubstring : "exceeds maximum allowed value" ,
8787 },
88- {
89- name : "supported operator with capacity of zero" ,
90- value : "0" ,
91- operator : placementv1beta1 .PropertySelectorGreaterThan ,
92- wantValue : 0 ,
93- wantError : false ,
94- },
9588 {
9689 name : "capacity equal to max limit with supported operator" ,
9790 value : "200" ,
9891 operator : placementv1beta1 .PropertySelectorGreaterThanOrEqualTo ,
99- wantValue : 199 ,
92+ wantValue : 200 ,
10093 wantError : false ,
10194 },
10295 {
@@ -107,12 +100,19 @@ func TestValidateCapacity(t *testing.T) {
107100 errorSubstring : "exceeds maximum allowed value" ,
108101 },
109102 {
110- name : "capacity at minimum limit" ,
111- value : "1 " ,
103+ name : "capacity at minimum limit (Gt) " ,
104+ value : "0 " ,
112105 operator : placementv1beta1 .PropertySelectorGreaterThan ,
113106 wantValue : 1 ,
114107 wantError : false ,
115108 },
109+ {
110+ name : "capacity at minimum limit (Ge)" ,
111+ value : "1" ,
112+ operator : placementv1beta1 .PropertySelectorGreaterThanOrEqualTo ,
113+ wantValue : 1 ,
114+ wantError : false ,
115+ },
116116 }
117117 for _ , tt := range tests {
118118 t .Run (tt .name , func (t * testing.T ) {
@@ -158,7 +158,7 @@ func TestExtractCapacityRequirements(t *testing.T) {
158158 Values : []string {"4" },
159159 },
160160 wantSKU : "Standard_D4s_v3" ,
161- wantCapacityValue : 4 ,
161+ wantCapacityValue : 5 ,
162162 wantError : false ,
163163 },
164164 {
@@ -172,6 +172,17 @@ func TestExtractCapacityRequirements(t *testing.T) {
172172 wantError : true ,
173173 errorSubstring : "exceeds maximum allowed value of 200" ,
174174 },
175+ {
176+ name : "invalid Azure SKU capacity property below min limit (Ge)" ,
177+ req : placementv1beta1.PropertySelectorRequirement {
178+ Name : fmt .Sprintf (azure .CapacityPerSKUPropertyTmpl , "Standard_B2ms" ),
179+ Operator : placementv1beta1 .PropertySelectorGreaterThanOrEqualTo ,
180+ Values : []string {"0" },
181+ },
182+ wantSKU : "Standard_B2ms" ,
183+ wantError : true ,
184+ errorSubstring : "is below minimum allowed value" ,
185+ },
175186 {
176187 name : "invalid Azure SKU capacity property with decimal" ,
177188 req : placementv1beta1.PropertySelectorRequirement {
@@ -281,7 +292,7 @@ func TestExtractCapacityRequirements(t *testing.T) {
281292}
282293
283294func TestCheckIfMeetSKUCapacityRequirement (t * testing.T ) {
284- // Prepare test data
295+ // Prepare test data.
285296 validSKU := "Standard_D2s_v3"
286297 validPropertySelectorRequirement := placementv1beta1.PropertySelectorRequirement {
287298 Name : fmt .Sprintf (azure .CapacityPerSKUPropertyTmpl , validSKU ),
@@ -312,7 +323,7 @@ func TestCheckIfMeetSKUCapacityRequirement(t *testing.T) {
312323 name : "valid capacity request" ,
313324 cluster : cluster ,
314325 sku : validSKU ,
315- targetCapacity : 3 ,
326+ targetCapacity : 4 ,
316327 req : validPropertySelectorRequirement ,
317328 mockStatusCode : http .StatusOK ,
318329 wantAvailable : true ,
@@ -322,7 +333,7 @@ func TestCheckIfMeetSKUCapacityRequirement(t *testing.T) {
322333 name : "unavailable SKU request" ,
323334 cluster : cluster ,
324335 sku : "Standard_D2s_v4" ,
325- targetCapacity : 1 ,
336+ targetCapacity : 2 ,
326337 req : placementv1beta1.PropertySelectorRequirement {
327338 Name : fmt .Sprintf (azure .CapacityPerSKUPropertyTmpl , "Standard_D2s_v4" ),
328339 Operator : placementv1beta1 .PropertySelectorGreaterThanOrEqualTo ,
@@ -381,7 +392,7 @@ func TestCheckIfMeetSKUCapacityRequirement(t *testing.T) {
381392 name : "Azure API returns error" ,
382393 cluster : cluster ,
383394 sku : validSKU ,
384- targetCapacity : 3 ,
395+ targetCapacity : 4 ,
385396 req : validPropertySelectorRequirement ,
386397 mockStatusCode : http .StatusInternalServerError ,
387398 wantError : true ,
@@ -402,7 +413,7 @@ func TestCheckIfMeetSKUCapacityRequirement(t *testing.T) {
402413 errorSubstring : "unsupported operator \" Eq\" for SKU capacity property, only GreaterThan (Gt) and GreaterThanOrEqualTo (Ge) are supported" ,
403414 },
404415 {
405- name : "unsupported operator in requirement" ,
416+ name : "too low value in requirement" ,
406417 cluster : cluster ,
407418 sku : validSKU ,
408419 targetCapacity : 0 ,
@@ -411,15 +422,14 @@ func TestCheckIfMeetSKUCapacityRequirement(t *testing.T) {
411422 Operator : placementv1beta1 .PropertySelectorGreaterThanOrEqualTo ,
412423 Values : []string {"0" },
413424 },
414- mockStatusCode : http .StatusOK ,
415425 wantError : true ,
416- errorSubstring : "capacity value cannot be zero for operator " ,
426+ errorSubstring : "is below minimum allowed value " ,
417427 },
418428 {
419429 name : "cases-insensitive request - available SKU" ,
420430 cluster : cluster ,
421431 sku : "STANDARD_D2S_V3" ,
422- targetCapacity : 1 ,
432+ targetCapacity : 2 ,
423433 req : placementv1beta1.PropertySelectorRequirement {
424434 Name : fmt .Sprintf (azure .CapacityPerSKUPropertyTmpl , "STANDARD_D2S_V3" ),
425435 Operator : placementv1beta1 .PropertySelectorGreaterThanOrEqualTo ,
0 commit comments