zhuqi-lucas commented on code in PR #465:
URL: https://github.com/apache/yunikorn-core/pull/465#discussion_r1040659067


##########
pkg/webservice/handlers_test.go:
##########
@@ -1358,6 +1376,34 @@ func TestUsersAndGroupsResourceUsage(t *testing.T) {
        assert.Equal(t, usersResourceUsageDao[0].Queues.ResourceUsage.String(),
                
resources.NewResourceFromMap(map[string]resources.Quantity{siCommon.CPU: 
1}).String())
 
+       // Test existed user query
+       req, err = http.NewRequest("GET", 
"/ws/v1/partition/default/usage/user/testuser", strings.NewReader(""))
+       vars := map[string]string{
+               "user":  "testuser",
+               "group": "testgroup",
+       }
+       req = mux.SetURLVars(req, vars)
+       assert.NilError(t, err, "Get User Resource Usage Handler request 
failed")
+       resp = &MockResponseWriter{}
+       var userResourceUsageDao *dao.UserResourceUsageDAOInfo
+       getUserResourceUsage(resp, req)
+       err = json.Unmarshal(resp.outputBytes, &userResourceUsageDao)
+       assert.NilError(t, err, "failed to unmarshal user resource usage dao 
response from response body: %s", string(resp.outputBytes))
+       assert.Equal(t, userResourceUsageDao.Queues.ResourceUsage.String(),
+               
resources.NewResourceFromMap(map[string]resources.Quantity{siCommon.CPU: 
1}).String())
+
+       // Test non-existing user query
+       req, err = http.NewRequest("GET", 
"/ws/v1/partition/default/usage/user/testNonExistingUser", 
strings.NewReader(""))
+       vars = map[string]string{
+               "user":  "testNonExistingUser",
+               "group": "testgroup",
+       }
+       req = mux.SetURLVars(req, vars)
+       assert.NilError(t, err, "Get User Resource Usage Handler request 
failed")
+       resp = &MockResponseWriter{}
+       getUserResourceUsage(resp, req)
+       assertUserExists(t, resp)
+

Review Comment:
   Thank you @manirajv06 , Good suggestion! 



-- 
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