I am working on Rest API project in golang. Assume I have a handler for routing and service which will do the application logic for the handler functions.
in handler.go
...
var userDto UserDto
err = UserService.UpdateUser(ctx, &userDto)
if err != nil {
c.AbortWithStatus(http.StatusNotFound)
return
}
...
I am using pointer reference in my service package functions.
Now I am writing a unit test for handler there I am going to mock the userService. But while mocking I can write like
suite.userServiceMock.On("UpdateUser", mock.Anything, userDto).Return(nil)
But here I have the option only to change the error return, not the Dto. I will be glad if someone helps me with this scenario.
Aucun commentaire:
Enregistrer un commentaire