-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SAC-5 Update User PATCH #28
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job @michael-brennan2005 & @melodyyu754 👏 ❗Some minor feedback and some things @DOOduneye and I have to figure out. Super solid PR and attention to detail. So proud 😁
frontend/yarn.lock
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we untrack this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ignore this, we need to track it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we untrack this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good stuff! conceptual question for you guys, should adding an approved email domain require a code change 🤔 ? see the config directory and config.go for how we could handle this 🦀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we test this validation here
@@ -39,3 +40,121 @@ func TestGetAllUsersWorks(t *testing.T) { | |||
// assert that the user returned from the database is the same as the user returned from the API | |||
assert.Equal(dbUser, respUser) | |||
} | |||
|
|||
func TestUpdateUserWorks(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see this new PR for an improvement to our testing helpers!
) | ||
|
||
func ValidateEmail(fl validator.FieldLevel) bool { | ||
email, err := emailaddress.Parse(fl.Field().String()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be worth it to take advantage of regex over importing a utility if you have the time
Co-authored-by: edwinliiiii <[email protected]> Co-authored-by: edwinliiiii <[email protected]> Co-authored-by: Garrett Ladley <[email protected]> Co-authored-by: garrettladley <[email protected]>
backend/src/transactions/user.go
Outdated
@@ -16,3 +16,22 @@ func GetAllUsers(db *gorm.DB) ([]models.User, error) { | |||
|
|||
return users, nil | |||
} | |||
|
|||
func UpdateUser(db *gorm.DB, id string, user models.User) (*models.User, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func UpdateUser(db *gorm.DB, id string, user models.User) (*models.User, error) { | |
func UpdateUser(db *gorm.DB, id uint, user models.User) (*models.User, error) { |
backend/src/services/user.go
Outdated
@@ -19,3 +23,30 @@ type UserService struct { | |||
func (u *UserService) GetAllUsers() ([]models.User, error) { | |||
return transactions.GetAllUsers(u.DB) | |||
} | |||
|
|||
// Updates a user | |||
func (u *UserService) UpdateUser(id string, params models.UpdateUserRequestBody) (*models.User, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for standardization, use utilities.ValidateID
to validate and convert id into a uint at some point before passing id to transaction. see UpdateTag for inspo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also see my reply to your message on Slack
Co-authored-by: Melody Yu <[email protected]> Co-authored-by: Garrett Ladley <[email protected]> Co-authored-by: Zackary Lassetter <[email protected]> Co-authored-by: edwinliiiii <[email protected]> Co-authored-by: edwinliiiii <[email protected]> Co-authored-by: garrettladley <[email protected]> Co-authored-by: David Oduneye <[email protected]> Co-authored-by: David Oduneye <[email protected]>
Description
Link to Ticket
This PR:
UserParams
struct for validation and creating amodels.User
from, and which can hopefully be reused for POST create user requests.How Has This Been Tested?
3 Tests can be found in
tests/user_test.go
:Checklist