diff --git a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md index 7748e23..4e3db6c 100644 --- a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md +++ b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md @@ -3,6 +3,7 @@ - [ ]  New features - [ ]  Bug fixes - [ ]  Breaking changes +- [ ] Refactor ## Describe what you have done - ### New Features diff --git a/internal/baan/test/baan.handler_test.go b/internal/baan/test/baan.handler_test.go index 7200988..c31e283 100644 --- a/internal/baan/test/baan.handler_test.go +++ b/internal/baan/test/baan.handler_test.go @@ -50,40 +50,36 @@ func (t *BaanHandlerTest) SetupTest() { } func (t *BaanHandlerTest) TestFindAllBaanSuccess() { + baanSvc := baanMock.NewMockService(t.controller) + validator := validatorMock.NewMockDtoValidator(t.controller) + context := routerMock.NewMockContext(t.controller) + handler := baan.NewHandler(baanSvc, validator, t.logger) + expectedResp := &dto.FindAllBaanResponse{ Baans: t.Baans, } - controller := gomock.NewController(t.T()) - - baanSvc := baanMock.NewMockService(controller) - validator := validatorMock.NewMockDtoValidator(controller) - context := routerMock.NewMockContext(controller) - baanSvc.EXPECT().FindAllBaan(t.FindAllBaanReq).Return(expectedResp, t.Err) context.EXPECT().JSON(http.StatusOK, expectedResp) - handler := baan.NewHandler(baanSvc, validator, t.logger) handler.FindAllBaan(context) } func (t *BaanHandlerTest) TestFindOneBaanSuccess() { + baanSvc := baanMock.NewMockService(t.controller) + validator := validatorMock.NewMockDtoValidator(t.controller) + context := routerMock.NewMockContext(t.controller) + handler := baan.NewHandler(baanSvc, validator, t.logger) + expectedResp := &dto.FindOneBaanResponse{ Baan: t.Baan, } - controller := gomock.NewController(t.T()) - - baanSvc := baanMock.NewMockService(controller) - validator := validatorMock.NewMockDtoValidator(controller) - context := routerMock.NewMockContext(controller) - context.EXPECT().Param("id").Return(t.ParamMock) validator.EXPECT().Validate(t.FindOneBaanReq).Return(nil) baanSvc.EXPECT().FindOneBaan(t.FindOneBaanReq).Return(expectedResp, t.Err) context.EXPECT().JSON(http.StatusOK, expectedResp) - handler := baan.NewHandler(baanSvc, validator, t.logger) handler.FindOneBaan(context) } diff --git a/internal/baan/test/baan.service_test.go b/internal/baan/test/baan.service_test.go index a3c8031..e7d783d 100644 --- a/internal/baan/test/baan.service_test.go +++ b/internal/baan/test/baan.service_test.go @@ -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" ) @@ -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() {