diff --git a/internal/gapi/get_user_by_id_test.go b/internal/gapi/get_user_by_id_test.go index 812bdc6..1538360 100644 --- a/internal/gapi/get_user_by_id_test.go +++ b/internal/gapi/get_user_by_id_test.go @@ -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" ) @@ -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) + } }