Skip to content

Commit

Permalink
fix: pet tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bookpanda committed Jan 9, 2024
1 parent 66522a5 commit 73d4a04
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
15 changes: 11 additions & 4 deletions src/app/handler/pet/pet.handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,28 @@ 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(),
Type: faker.Word(),
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: "",
Expand All @@ -84,14 +89,16 @@ 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),
IsSterile: &t.Pet.IsSterile,
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,
Expand Down
22 changes: 16 additions & 6 deletions src/app/service/pet/pet.service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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++ {
Expand All @@ -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(),
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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{},
Expand All @@ -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,
Expand All @@ -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{},
Expand All @@ -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,
Expand Down

0 comments on commit 73d4a04

Please sign in to comment.