Skip to content

Commit

Permalink
fix: sfvc test
Browse files Browse the repository at this point in the history
  • Loading branch information
bookpanda committed Jun 23, 2024
1 parent 1d81a52 commit c444d28
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions internal/baan/test/baan.service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/isd-sgcu/rpkm67-gateway/internal/dto"
baanMock "github.com/isd-sgcu/rpkm67-gateway/mocks/client/baan"
baanProto "github.com/isd-sgcu/rpkm67-go-proto/rpkm67/backend/baan/v1"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
"go.uber.org/zap"
)
Expand Down Expand Up @@ -53,43 +52,40 @@ func (t *BaanServiceTest) SetupTest() {
}

func (t *BaanServiceTest) TestFindAllBaanSuccess() {
client := baanMock.BaanClientMock{}
svc := baan.NewService(&client, t.logger)

protoResp := &baanProto.FindAllBaanResponse{
Baans: t.BaansProto,
}

findAllBaansDto := baan.ProtoToDtoList(protoResp.Baans)

expected := &dto.FindAllBaanResponse{
Baans: findAllBaansDto,
}

client := baanMock.BaanClientMock{}
client.On("FindAllBaan", t.FindAllBaanProtoReq).Return(protoResp, nil)

svc := baan.NewService(&client, t.logger)
actual, err := svc.FindAllBaan(t.FindAllBaanDtoReq)

assert.Nil(t.T(), err)
assert.Equal(t.T(), expected, actual)
t.Nil(err)
t.Equal(expected, actual)
}

func (t *BaanServiceTest) TestFindOneBaanSuccess() {
client := baanMock.BaanClientMock{}
svc := baan.NewService(&client, t.logger)

protoResp := &baanProto.FindOneBaanResponse{
Baan: t.BaanProto,
}

expected := &dto.FindOneBaanResponse{
Baan: t.BaanDto,
}

client := baanMock.BaanClientMock{}
client.On("FindOneBaan", t.FindOneBaanProtoReq).Return(protoResp, nil)

svc := baan.NewService(&client, t.logger)
actual, err := svc.FindOneBaan(t.FindOneBaanDtoReq)

assert.Nil(t.T(), err)
assert.Equal(t.T(), expected, actual)
t.Nil(err)
t.Equal(expected, actual)
}

func (t *BaanServiceTest) TearDownTest() {
Expand Down

0 comments on commit c444d28

Please sign in to comment.