@@ -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 : fmt . Sprintf ( "capacity value cannot be below minimum %d after adjustment" , minVMInstanceCapacity ) ,
8080 },
8181 {
8282 name : "capacity equal to max limit with GreaterThan operator" ,
@@ -86,11 +86,12 @@ func TestValidateCapacity(t *testing.T) {
8686 errorSubstring : "exceeds maximum allowed value" ,
8787 },
8888 {
89- name : "supported operator with capacity of zero" ,
90- value : "0" ,
91- operator : placementv1beta1 .PropertySelectorGreaterThan ,
92- wantValue : 0 ,
93- wantError : false ,
89+ name : "unsupported operator with capacity of 1" ,
90+ value : "1" ,
91+ operator : placementv1beta1 .PropertySelectorGreaterThanOrEqualTo ,
92+ wantValue : 0 ,
93+ wantError : true ,
94+ errorSubstring : fmt .Sprintf ("capacity value cannot be below minimum %d after adjustment" , minVMInstanceCapacity ),
9495 },
9596 {
9697 name : "capacity equal to max limit with supported operator" ,
@@ -113,6 +114,13 @@ func TestValidateCapacity(t *testing.T) {
113114 wantValue : 1 ,
114115 wantError : false ,
115116 },
117+ {
118+ name : "capacity at minimum limit after adjustment" ,
119+ value : "2" ,
120+ operator : placementv1beta1 .PropertySelectorGreaterThanOrEqualTo ,
121+ wantValue : 1 ,
122+ wantError : false ,
123+ },
116124 }
117125 for _ , tt := range tests {
118126 t .Run (tt .name , func (t * testing.T ) {
@@ -172,6 +180,17 @@ func TestExtractCapacityRequirements(t *testing.T) {
172180 wantError : true ,
173181 errorSubstring : "exceeds maximum allowed value of 200" ,
174182 },
183+ {
184+ name : "invalid Azure SKU capacity property exceeding min limit" ,
185+ req : placementv1beta1.PropertySelectorRequirement {
186+ Name : fmt .Sprintf (azure .CapacityPerSKUPropertyTmpl , "Standard_B2ms" ),
187+ Operator : placementv1beta1 .PropertySelectorGreaterThanOrEqualTo ,
188+ Values : []string {"1" },
189+ },
190+ wantSKU : "Standard_B2ms" ,
191+ wantError : true ,
192+ errorSubstring : fmt .Sprintf ("capacity value cannot be below minimum %d after adjustment" , minVMInstanceCapacity ),
193+ },
175194 {
176195 name : "invalid Azure SKU capacity property with decimal" ,
177196 req : placementv1beta1.PropertySelectorRequirement {
@@ -402,7 +421,7 @@ func TestCheckIfMeetSKUCapacityRequirement(t *testing.T) {
402421 errorSubstring : "unsupported operator \" Eq\" for SKU capacity property, only GreaterThan (Gt) and GreaterThanOrEqualTo (Ge) are supported" ,
403422 },
404423 {
405- name : "unsupported operator in requirement" ,
424+ name : "invalid value in requirement" ,
406425 cluster : cluster ,
407426 sku : validSKU ,
408427 targetCapacity : 0 ,
@@ -413,7 +432,7 @@ func TestCheckIfMeetSKUCapacityRequirement(t *testing.T) {
413432 },
414433 mockStatusCode : http .StatusOK ,
415434 wantError : true ,
416- errorSubstring : "capacity value cannot be zero for operator" ,
435+ errorSubstring : fmt . Sprintf ( "capacity value cannot be below minimum %d after adjustment" , minVMInstanceCapacity ) ,
417436 },
418437 {
419438 name : "cases-insensitive request - available SKU" ,
0 commit comments