Skip to content

Commit

Permalink
fix: unit test pet
Browse files Browse the repository at this point in the history
  • Loading branch information
bookpanda committed Feb 20, 2024
1 parent 23292bb commit cb4ff13
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/app/service/pet/pet.service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,13 @@ func (t *PetServiceTest) TestDeleteNotFound() {
protoResp := &petproto.DeletePetResponse{
Success: false,
}
imageProtoReq := &imgproto.DeleteByPetIdRequest{
PetId: t.Pet.Id,
}
imageProtoResp := &imgproto.DeleteByPetIdResponse{
Success: true,
}

clientErr := status.Error(codes.NotFound, constant.PetNotFoundMessage)

expected := t.NotFoundErr
Expand All @@ -586,6 +593,7 @@ func (t *PetServiceTest) TestDeleteNotFound() {
client.On("Delete", protoReq).Return(protoResp, clientErr)

imageClient := imagemock.ImageClientMock{}
imageClient.On("DeleteByPetId", imageProtoReq).Return(imageProtoResp, nil)

imageSvc := imageSvc.NewService(&imageClient)
svc := NewService(client, imageSvc)
Expand All @@ -602,6 +610,13 @@ func (t *PetServiceTest) TestDeleteServiceUnavailableError() {
protoResp := &petproto.DeletePetResponse{
Success: false,
}
imageProtoReq := &imgproto.DeleteByPetIdRequest{
PetId: t.Pet.Id,
}
imageProtoResp := &imgproto.DeleteByPetIdResponse{
Success: true,
}

clientErr := status.Error(codes.Unavailable, constant.UnavailableServiceMessage)

expected := t.UnavailableServiceErr
Expand All @@ -610,6 +625,7 @@ func (t *PetServiceTest) TestDeleteServiceUnavailableError() {
client.On("Delete", protoReq).Return(protoResp, clientErr)

imageClient := imagemock.ImageClientMock{}
imageClient.On("DeleteByPetId", imageProtoReq).Return(imageProtoResp, nil)

imageSvc := imageSvc.NewService(&imageClient)
svc := NewService(client, imageSvc)
Expand Down

0 comments on commit cb4ff13

Please sign in to comment.