Skip to content

Commit

Permalink
fix: call imgSrv FindByPetId on TestChangeViewSuccess
Browse files Browse the repository at this point in the history
  • Loading branch information
macgeargear committed Dec 26, 2023
1 parent a789156 commit 8d7d7e5
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/app/service/pet/pet.service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package pet
import (
"context"
"errors"
"fmt"
"math/rand"
"testing"
"time"
Expand Down Expand Up @@ -76,7 +75,7 @@ func (t *PetServiceTest) SetupTest() {
var images []*img_proto.Image
var imageUrls []string
for i := 0; i < 3; i++ {
url := fmt.Sprintf("http://www.image.pet.%v", i)
url := faker.URL()
images = append(images, &img_proto.Image{
Id: faker.UUIDDigit(),
PetId: pet.ID.String(),
Expand Down Expand Up @@ -319,7 +318,6 @@ func (t *PetServiceTest) TestFindAllSuccess() {
imgSrv := new(img_mock.ServiceMock)
for i, pet := range t.Pets {
imgSrv.On("FindByPetId", pet.ID.String()).Return(t.ImagesList[i], nil)
fmt.Println(len(t.ImageUrlsList[i]))
}

srv := NewService(repo, imgSrv)
Expand Down Expand Up @@ -517,6 +515,7 @@ func (t *PetServiceTest) TestChangeViewSuccess() {
repo.On("FindOne", t.Pet.ID.String(), &pet.Pet{}).Return(t.Pet, nil)
repo.On("Update", t.Pet.ID.String(), t.ChangeViewPet).Return(t.ChangeViewPet, nil)
imgSrv := new(img_mock.ServiceMock)
imgSrv.On("FindByPetId", t.Pet.ID.String()).Return(t.Images, nil)

srv := NewService(repo, imgSrv)
actual, err := srv.ChangeView(context.Background(), t.ChangeViewPetReqMock)
Expand Down

0 comments on commit 8d7d7e5

Please sign in to comment.