wilfred-s commented on code in PR #691:
URL: https://github.com/apache/yunikorn-core/pull/691#discussion_r1387371601


##########
pkg/common/resources/resources_test.go:
##########
@@ -1701,3 +1701,29 @@ func TestIsEmpty(t *testing.T) {
                })
        }
 }
+
+func TestResource_DominantResource(t *testing.T) {
+       tests := []struct {
+               name     string
+               used     *Resource
+               capacity *Resource
+               wantName string
+       }{
+               {"nil receiver", nil, Zero, ""},
+               {"nil cap", Zero, nil, ""},
+               {"zero cap", NewResourceFromMap(map[string]Quantity{"A": 10}), 
Zero, ""},
+               {"over cap", NewResourceFromMap(map[string]Quantity{"A": 20}), 
NewResourceFromMap(map[string]Quantity{"A": 10}), "A"},
+               {"zero usage exist", 
NewResourceFromMap(map[string]Quantity{"A": 0}), 
NewResourceFromMap(map[string]Quantity{"A": 10}), "A"},
+               {"usage not in cap", 
NewResourceFromMap(map[string]Quantity{"B": 10}), 
NewResourceFromMap(map[string]Quantity{"A": 10}), ""},
+               {"multiple usages", NewResourceFromMap(map[string]Quantity{"B": 
10, "A": 10}), NewResourceFromMap(map[string]Quantity{"A": 10, "B": 20}), "A"},
+               {"0 usage with 0 cap", 
NewResourceFromMap(map[string]Quantity{"A": 0}), 
NewResourceFromMap(map[string]Quantity{"A": 0}), "A"},

Review Comment:
   See below special cased both values 0 case 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to