Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

Commit

Permalink
test: added InvalidArgument case check for GetUserById
Browse files Browse the repository at this point in the history
  • Loading branch information
ansh-devs committed May 31, 2024
1 parent 250b7df commit a55fe18
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/gapi/get_user_by_id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"github.com/ansh-devs/tc-assessment/internal/database"
"github.com/ansh-devs/tc-assessment/protos"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/grpc/test/bufconn"
)

Expand Down Expand Up @@ -53,4 +55,10 @@ func TestUserService_GetuserById(t *testing.T) {
if resp.GetUser().FName != "Nerita Bomfield" {
t.Fatalf("Unexpected values %v", resp.User)
}
// Case when out of bound id is passed resulting in InvalidArgument proto error
_, err = client.GetUserById(context.Background(), &protos.GetUserByIdRequest{Id: 20})
code, _ := status.FromError(err)
if code.Code() != codes.InvalidArgument {
t.Fatalf("GetUserById error Invalid Argument unexpected code %v", err)
}
}

0 comments on commit a55fe18

Please sign in to comment.