From 73d4a048aee8b70d50fe224b3c1a2cb09f02f801 Mon Sep 17 00:00:00 2001 From: Idhibhat Pankam Date: Wed, 10 Jan 2024 01:03:58 +0700 Subject: [PATCH] fix: pet tests --- src/app/handler/pet/pet.handler_test.go | 15 +++++++++++---- src/app/service/pet/pet.service_test.go | 22 ++++++++++++++++------ 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/app/handler/pet/pet.handler_test.go b/src/app/handler/pet/pet.handler_test.go index 659e221..d720170 100644 --- a/src/app/handler/pet/pet.handler_test.go +++ b/src/app/handler/pet/pet.handler_test.go @@ -49,6 +49,9 @@ func (t *PetHandlerTest) SetupTest() { t.ImagesList = imagesList t.Images = imagesList[0] var pets []*petProto.Pet + genders := []petConst.Gender{petConst.MALE, petConst.FEMALE} + statuses := []petConst.Status{petConst.ADOPTED, petConst.FINDHOME} + for i := 0; i <= 3; i++ { pet := &petProto.Pet{ Id: faker.UUIDDigit(), @@ -56,16 +59,18 @@ func (t *PetHandlerTest) SetupTest() { Species: faker.Word(), Name: faker.Name(), Birthdate: faker.Word(), - Gender: petProto.Gender(rand.Intn(1) + 1), + Gender: string(genders[rand.Intn(2)]), + Color: faker.Word(), + Pattern: faker.Word(), Habit: faker.Paragraph(), Caption: faker.Paragraph(), Images: []*imgProto.Image{}, - Status: petProto.PetStatus(rand.Intn(1) + 1), + Status: string(statuses[rand.Intn(2)]), IsSterile: true, IsVaccinated: true, IsVisible: true, IsClubPet: true, - Background: faker.Paragraph(), + Origin: faker.Paragraph(), Address: faker.Paragraph(), Contact: faker.Paragraph(), AdoptBy: "", @@ -84,6 +89,8 @@ func (t *PetHandlerTest) SetupTest() { Name: t.Pet.Name, Birthdate: t.Pet.Birthdate, Gender: pet.Gender(t.Pet.Gender), + Color: t.Pet.Color, + Pattern: t.Pet.Pattern, Habit: t.Pet.Habit, Caption: t.Pet.Caption, Status: pet.Status(t.Pet.Status), @@ -91,7 +98,7 @@ func (t *PetHandlerTest) SetupTest() { IsVaccinated: &t.Pet.IsVaccinated, IsVisible: &t.Pet.IsVisible, IsClubPet: &t.Pet.IsClubPet, - Background: t.Pet.Background, + Origin: t.Pet.Origin, Address: t.Pet.Address, Contact: t.Pet.Contact, AdoptBy: t.Pet.AdoptBy, diff --git a/src/app/service/pet/pet.service_test.go b/src/app/service/pet/pet.service_test.go index 5705c12..f32efac 100644 --- a/src/app/service/pet/pet.service_test.go +++ b/src/app/service/pet/pet.service_test.go @@ -51,6 +51,8 @@ func (t *PetServiceTest) SetupTest() { imagesList := utils.MockImageList(3) t.ImagesList = imagesList t.Images = imagesList[0] + genders := []pet.Gender{pet.MALE, pet.FEMALE} + statuses := []pet.Status{pet.ADOPTED, pet.FINDHOME} var pets []*petproto.Pet for i := 0; i <= 3; i++ { @@ -60,16 +62,18 @@ func (t *PetServiceTest) SetupTest() { Species: faker.Word(), Name: faker.Name(), Birthdate: faker.Word(), - Gender: petproto.Gender(rand.Intn(1) + 1), + Gender: string(genders[rand.Intn(2)]), + Color: faker.Word(), + Pattern: faker.Word(), Habit: faker.Paragraph(), Caption: faker.Paragraph(), Images: imagesList[i], - Status: petproto.PetStatus(rand.Intn(1) + 1), + Status: string(statuses[rand.Intn(2)]), IsSterile: true, IsVaccinated: true, IsVisible: true, IsClubPet: true, - Background: faker.Paragraph(), + Origin: faker.Paragraph(), Address: faker.Paragraph(), Contact: faker.Paragraph(), AdoptBy: faker.UUIDDigit(), @@ -88,6 +92,8 @@ func (t *PetServiceTest) SetupTest() { Name: t.Pet.Name, Birthdate: t.Pet.Birthdate, Gender: t.Pet.Gender, + Color: t.Pet.Color, + Pattern: t.Pet.Pattern, Habit: t.Pet.Habit, Caption: t.Pet.Caption, Images: t.Pet.Images, @@ -96,7 +102,7 @@ func (t *PetServiceTest) SetupTest() { IsVaccinated: t.Pet.IsVaccinated, IsVisible: false, IsClubPet: t.Pet.IsClubPet, - Background: t.Pet.Background, + Origin: t.Pet.Origin, Address: t.Pet.Address, Contact: t.Pet.Contact, AdoptBy: t.Pet.AdoptBy, @@ -110,6 +116,8 @@ func (t *PetServiceTest) SetupTest() { Name: t.Pet.Name, Birthdate: t.Pet.Birthdate, Gender: pet.Gender(t.Pet.Gender), + Color: t.Pet.Color, + Pattern: t.Pet.Pattern, Habit: t.Pet.Habit, Caption: t.Pet.Caption, Images: []string{}, @@ -118,7 +126,7 @@ func (t *PetServiceTest) SetupTest() { IsVaccinated: &t.Pet.IsVaccinated, IsVisible: &t.Pet.IsVisible, IsClubPet: &t.Pet.IsClubPet, - Background: t.Pet.Background, + Origin: t.Pet.Origin, Address: t.Pet.Address, Contact: t.Pet.Contact, AdoptBy: t.Pet.AdoptBy, @@ -130,6 +138,8 @@ func (t *PetServiceTest) SetupTest() { Name: t.Pet.Name, Birthdate: t.Pet.Birthdate, Gender: pet.Gender(t.Pet.Gender), + Color: t.Pet.Color, + Pattern: t.Pet.Pattern, Habit: t.Pet.Habit, Caption: t.Pet.Caption, Images: []string{}, @@ -138,7 +148,7 @@ func (t *PetServiceTest) SetupTest() { IsVaccinated: &t.Pet.IsVaccinated, IsVisible: &t.Pet.IsVisible, IsClubPet: &t.Pet.IsClubPet, - Background: t.Pet.Background, + Origin: t.Pet.Origin, Address: t.Pet.Address, Contact: t.Pet.Contact, AdoptBy: t.Pet.AdoptBy,