Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YUNIKORN-2123] Modify json.Unmarshal error message #698

Closed
wants to merge 8 commits into from
18 changes: 9 additions & 9 deletions pkg/webservice/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@ func TestGetApplicationHandler(t *testing.T) {
func assertParamsMissing(t *testing.T, resp *MockResponseWriter) {
var errInfo dao.YAPIError
err := json.Unmarshal(resp.outputBytes, &errInfo)
assert.NilError(t, err, "failed to unmarshal applications dao response from response body")
assert.NilError(t, err, "failed to unmarshal DAOInfo response from response body")
assert.Equal(t, http.StatusBadRequest, resp.statusCode, "Incorrect Status code")
assert.Equal(t, errInfo.Message, MissingParamsName, "JSON error message is incorrect")
assert.Equal(t, errInfo.StatusCode, http.StatusBadRequest)
Expand All @@ -1208,7 +1208,7 @@ func assertParamsMissing(t *testing.T, resp *MockResponseWriter) {
func assertPartitionExists(t *testing.T, resp *MockResponseWriter) {
var errInfo dao.YAPIError
err := json.Unmarshal(resp.outputBytes, &errInfo)
assert.NilError(t, err, "failed to unmarshal applications dao response from response body")
assert.NilError(t, err, "failed to unmarshal PartitionQueueDAOInfo response from response body")
assert.Equal(t, http.StatusBadRequest, resp.statusCode, "Incorrect Status code")
assert.Equal(t, errInfo.Message, PartitionDoesNotExists, "JSON error message is incorrect")
assert.Equal(t, errInfo.StatusCode, http.StatusBadRequest)
Expand All @@ -1217,7 +1217,7 @@ func assertPartitionExists(t *testing.T, resp *MockResponseWriter) {
func assertQueueExists(t *testing.T, resp *MockResponseWriter) {
var errInfo dao.YAPIError
err := json.Unmarshal(resp.outputBytes, &errInfo)
assert.NilError(t, err, "failed to unmarshal applications dao response from response body")
assert.NilError(t, err, "failed to unmarshal ApplicationDAOInfo response from response body")
assert.Equal(t, http.StatusBadRequest, resp.statusCode, "Incorrect Status code")
assert.Equal(t, errInfo.Message, QueueDoesNotExists, "JSON error message is incorrect")
assert.Equal(t, errInfo.StatusCode, http.StatusBadRequest)
Expand All @@ -1226,7 +1226,7 @@ func assertQueueExists(t *testing.T, resp *MockResponseWriter) {
func assertApplicationExists(t *testing.T, resp *MockResponseWriter) {
var errInfo dao.YAPIError
err := json.Unmarshal(resp.outputBytes, &errInfo)
assert.NilError(t, err, "failed to unmarshal applications dao response from response body")
assert.NilError(t, err, "failed to unmarshal ApplicationDAOInfo 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.StatusCode, http.StatusBadRequest)
Expand All @@ -1235,7 +1235,7 @@ func assertApplicationExists(t *testing.T, resp *MockResponseWriter) {
func assertUserExists(t *testing.T, resp *MockResponseWriter) {
var errInfo dao.YAPIError
err := json.Unmarshal(resp.outputBytes, &errInfo)
assert.NilError(t, err, "failed to unmarshal applications dao response from response body")
assert.NilError(t, err, "failed to unmarshal UserResourceUsageDAOInfo 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.StatusCode, http.StatusBadRequest)
Expand All @@ -1244,7 +1244,7 @@ func assertUserExists(t *testing.T, resp *MockResponseWriter) {
func assertUserNameExists(t *testing.T, resp *MockResponseWriter) {
var errInfo dao.YAPIError
err := json.Unmarshal(resp.outputBytes, &errInfo)
assert.NilError(t, err, "failed to unmarshal applications dao response from response body")
assert.NilError(t, err, "failed to unmarshal UserResourceUsageDAOInfo 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.StatusCode, http.StatusBadRequest)
Expand All @@ -1253,7 +1253,7 @@ func assertUserNameExists(t *testing.T, resp *MockResponseWriter) {
func assertGroupExists(t *testing.T, resp *MockResponseWriter) {
var errInfo dao.YAPIError
err := json.Unmarshal(resp.outputBytes, &errInfo)
assert.NilError(t, err, "failed to unmarshal applications dao response from response body")
assert.NilError(t, err, "failed to unmarshal GroupResourceUsageDAOInfo 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.StatusCode, http.StatusBadRequest)
Expand All @@ -1262,7 +1262,7 @@ func assertGroupExists(t *testing.T, resp *MockResponseWriter) {
func assertGroupNameExists(t *testing.T, resp *MockResponseWriter) {
var errInfo dao.YAPIError
err := json.Unmarshal(resp.outputBytes, &errInfo)
assert.NilError(t, err, "failed to unmarshal applications dao response from response body")
assert.NilError(t, err, "failed to unmarshal GroupResourceUsageDAOInfo 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.StatusCode, http.StatusBadRequest)
Expand All @@ -1271,7 +1271,7 @@ func assertGroupNameExists(t *testing.T, resp *MockResponseWriter) {
func assertNodeIDExists(t *testing.T, resp *MockResponseWriter) {
var errInfo dao.YAPIError
err := json.Unmarshal(resp.outputBytes, &errInfo)
assert.NilError(t, err, "failed to unmarshal node dao response from response body")
assert.NilError(t, err, "failed to unmarshal NodesDAOInfo 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.StatusCode, http.StatusBadRequest)
Expand Down