Skip to content

Commit

Permalink
Add unit tests for AuthHandlers
Browse files Browse the repository at this point in the history
This commit introduces a set of unit tests for the AuthHandlers in the API. Each test case covers a specific functionality, such as SignUp, SignIn, GetUser, DeleteUser, ChangeUserRole, UpdateUserPassword, UpdateUserEmail, UpdateUserName, and ListUsers. Custom mock client wrappers are used to simulate the behavior of the gRPC service calls, ensuring that the handlers interact correctly with the AuthService. The tests aim to improve the test coverage and validate the correctness of the authentication-related endpoints.
  • Loading branch information
mtnmunuklu committed Feb 4, 2024
1 parent 8a4d4b2 commit d0854e0
Show file tree
Hide file tree
Showing 4 changed files with 458 additions and 521 deletions.
6 changes: 3 additions & 3 deletions api/handlers/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type AuthHandlers interface {
UpdateUserPassword(c *fiber.Ctx) error
UpdateUserEmail(c *fiber.Ctx) error
UpdateUserName(c *fiber.Ctx) error
GetUsers(c *fiber.Ctx) error
ListUsers(c *fiber.Ctx) error
}

// authHandlers provides a connection with authentication service over proto buffer.
Expand Down Expand Up @@ -193,8 +193,8 @@ func (h *authHandlers) UpdateUserName(c *fiber.Ctx) error {
return util.WriteAsJSON(c, http.StatusOK, updatedUser)
}

// GetUsers lists all users.
func (h *authHandlers) GetUsers(c *fiber.Ctx) error {
// ListUsers lists all users.
func (h *authHandlers) ListUsers(c *fiber.Ctx) error {
userId, err := util.GetUserIDFromToken(c)
if err != nil {
return util.WriteError(c, http.StatusBadRequest, err)
Expand Down
Loading

0 comments on commit d0854e0

Please sign in to comment.