Skip to content

Commit

Permalink
fix: implement requested change
Browse files Browse the repository at this point in the history
  • Loading branch information
Devansh-bit committed Dec 17, 2023
1 parent 62afb55 commit 6d66ded
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 23 deletions.
10 changes: 0 additions & 10 deletions controllers/project_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
15 changes: 2 additions & 13 deletions controllers/project_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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."})
Expand Down

0 comments on commit 6d66ded

Please sign in to comment.