I'm new to writing tests, so I have a UserService that looks like this:
func (userService *UserService) Authenticate(email string, passwordAttempt string) (*Login, bool) {
...
return login, true
}
How would I go about writing a unit test for this function?
Do I mock my userService somehow?
type UserService struct {
deps *ServiceDeps
}
type ServiceDeps struct {
db *gorm.DB
}
The examples I've seen are for just functions, not when it is run on a struct that has other dependencies.
How would I go about writing a unit test?