From 6d66dedf7f7a0c5fc7b97977e92cb2534d435050 Mon Sep 17 00:00:00 2001 From: Devansh-bit Date: Sun, 17 Dec 2023 23:21:51 +0530 Subject: [PATCH] fix: implement requested change --- controllers/project_update.go | 10 ---------- controllers/project_update_test.go | 15 ++------------- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/controllers/project_update.go b/controllers/project_update.go index 9c78d22..6750c29 100644 --- a/controllers/project_update.go +++ b/controllers/project_update.go @@ -124,16 +124,6 @@ func UpdateProject(w http.ResponseWriter, r *http.Request) { ) return } - if tx.Error == gorm.ErrRecordNotFound { - utils.LogErrAndRespond( - r, - w, - err, - fmt.Sprintf("Secondary mentor `%s` does not exist.", reqFields.SecondaryMentorUsername), - http.StatusBadRequest, - ) - return - } } updatedProj := &models.Project{ diff --git a/controllers/project_update_test.go b/controllers/project_update_test.go index fca3c0d..237cf60 100644 --- a/controllers/project_update_test.go +++ b/controllers/project_update_test.go @@ -110,24 +110,13 @@ func tProjectUpdateExistent(db *gorm.DB, testUsername string, testJwt string, t ReadmeLink: "http://NewRepoLink/README", } - // Test with invalid new secondary mentor - projUpdateFields.SecondaryMentorUsername = "non-existent" - - req := createProjectUpdateRequest(projUpdateFields) - req.Header.Add("Bearer", testJwt) - - res := executeRequest(req, db) - - expectStatusCodeToBe(t, res, http.StatusBadRequest) - expectResponseJSONBodyToBe(t, res, utils.HTTPMessage{StatusCode: http.StatusBadRequest, Message: fmt.Sprintf("Secondary mentor `%s` does not exist.", projUpdateFields.SecondaryMentorUsername)}) - // Test with a valid new secondary mentor projUpdateFields.SecondaryMentorUsername = "testSecondary" - req = createProjectUpdateRequest(projUpdateFields) + req := createProjectUpdateRequest(projUpdateFields) req.Header.Add("Bearer", testJwt) - res = executeRequest(req, db) + res := executeRequest(req, db) expectStatusCodeToBe(t, res, http.StatusOK) expectResponseJSONBodyToBe(t, res, utils.HTTPMessage{StatusCode: http.StatusOK, Message: "Project successfully updated."})