This is an automated email from the ASF dual-hosted git repository.

mani pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/yunikorn-core.git


The following commit(s) were added to refs/heads/master by this push:
     new 37e7cd33 [YUNIKORN-2125] Remove literals from handlers_test.go (#699)
37e7cd33 is described below

commit 37e7cd33d3a9fca33d2c30335792ccc20eef7c89
Author: Michael Akinyemi <[email protected]>
AuthorDate: Tue Nov 7 10:36:15 2023 +0530

    [YUNIKORN-2125] Remove literals from handlers_test.go (#699)
    
    Some functions error message use string literals while others use constant 
variables available in the
    webservice pacakge. I replaced the hard coded messages with the 
corresponding constants.
    
    Closes: #699
    
    Signed-off-by: Manikandan R <[email protected]>
---
 pkg/webservice/handlers_test.go | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/pkg/webservice/handlers_test.go b/pkg/webservice/handlers_test.go
index be4166ff..136f6b1f 100644
--- a/pkg/webservice/handlers_test.go
+++ b/pkg/webservice/handlers_test.go
@@ -1228,7 +1228,7 @@ func assertApplicationExists(t *testing.T, resp 
*MockResponseWriter) {
        err := json.Unmarshal(resp.outputBytes, &errInfo)
        assert.NilError(t, err, "failed to unmarshal applications dao response 
from response body")
        assert.Equal(t, http.StatusBadRequest, resp.statusCode, "Incorrect 
Status code")
-       assert.Equal(t, errInfo.Message, "Application not found", "JSON error 
message is incorrect")
+       assert.Equal(t, errInfo.Message, ApplicationDoesNotExists, "JSON error 
message is incorrect")
        assert.Equal(t, errInfo.StatusCode, http.StatusBadRequest)
 }
 
@@ -1237,7 +1237,7 @@ func assertUserExists(t *testing.T, resp 
*MockResponseWriter) {
        err := json.Unmarshal(resp.outputBytes, &errInfo)
        assert.NilError(t, err, "failed to unmarshal applications dao response 
from response body")
        assert.Equal(t, http.StatusBadRequest, resp.statusCode, "Incorrect 
Status code")
-       assert.Equal(t, errInfo.Message, "User not found", "JSON error message 
is incorrect")
+       assert.Equal(t, errInfo.Message, UserDoesNotExists, "JSON error message 
is incorrect")
        assert.Equal(t, errInfo.StatusCode, http.StatusBadRequest)
 }
 
@@ -1246,7 +1246,7 @@ func assertUserNameExists(t *testing.T, resp 
*MockResponseWriter) {
        err := json.Unmarshal(resp.outputBytes, &errInfo)
        assert.NilError(t, err, "failed to unmarshal applications dao response 
from response body")
        assert.Equal(t, http.StatusBadRequest, resp.statusCode, "Incorrect 
Status code")
-       assert.Equal(t, errInfo.Message, "User name is missing", "JSON error 
message is incorrect")
+       assert.Equal(t, errInfo.Message, UserNameMissing, "JSON error message 
is incorrect")
        assert.Equal(t, errInfo.StatusCode, http.StatusBadRequest)
 }
 
@@ -1255,7 +1255,7 @@ func assertGroupExists(t *testing.T, resp 
*MockResponseWriter) {
        err := json.Unmarshal(resp.outputBytes, &errInfo)
        assert.NilError(t, err, "failed to unmarshal applications dao response 
from response body")
        assert.Equal(t, http.StatusBadRequest, resp.statusCode, "Incorrect 
Status code")
-       assert.Equal(t, errInfo.Message, "Group not found", "JSON error message 
is incorrect")
+       assert.Equal(t, errInfo.Message, GroupDoesNotExists, "JSON error 
message is incorrect")
        assert.Equal(t, errInfo.StatusCode, http.StatusBadRequest)
 }
 
@@ -1264,7 +1264,7 @@ func assertGroupNameExists(t *testing.T, resp 
*MockResponseWriter) {
        err := json.Unmarshal(resp.outputBytes, &errInfo)
        assert.NilError(t, err, "failed to unmarshal applications dao response 
from response body")
        assert.Equal(t, http.StatusBadRequest, resp.statusCode, "Incorrect 
Status code")
-       assert.Equal(t, errInfo.Message, "Group name is missing", "JSON error 
message is incorrect")
+       assert.Equal(t, errInfo.Message, GroupNameMissing, "JSON error message 
is incorrect")
        assert.Equal(t, errInfo.StatusCode, http.StatusBadRequest)
 }
 
@@ -1273,7 +1273,7 @@ func assertNodeIDExists(t *testing.T, resp 
*MockResponseWriter) {
        err := json.Unmarshal(resp.outputBytes, &errInfo)
        assert.NilError(t, err, "failed to unmarshal node dao response from 
response body")
        assert.Equal(t, http.StatusBadRequest, resp.statusCode, "Incorrect 
Status code")
-       assert.Equal(t, errInfo.Message, "Node not found", "JSON error message 
is incorrect")
+       assert.Equal(t, errInfo.Message, NodeDoesNotExists, "JSON error message 
is incorrect")
        assert.Equal(t, errInfo.StatusCode, http.StatusBadRequest)
 }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to