hritvikpatel4 commented on code in PR #6895:
URL: https://github.com/apache/trafficcontrol/pull/6895#discussion_r908643876
##########
traffic_ops/testing/api/v2/user_test.go:
##########
@@ -273,6 +273,30 @@ func UserSelfUpdateTest(t *testing.T) {
} else if *resp2[0].Email != currentEmail {
t.Errorf("Expected Email to still be '%s', but it was '%s'",
currentEmail, *resp2[0].Email)
}
+
+ // Now test using an invalid username
+ currentUsername := *user.Username
+ user.Username = new("ops man")
+ updateResp, _, err = TOSession.UpdateCurrentUser(user)
+ if err == nil {
+ t.Fatal("error was expected updating user with username: 'ops
man' - got none")
+ }
+
+ // Ensure it wasn't actually updated
+ resp2, _, err = TOSession.GetUserByID(*user.ID)
+ if err != nil {
+ t.Fatalf("error getting user #%d: %v", *user.ID, err)
+ }
+
+ if len(resp2) < 1 {
+ t.Fatalf("no user returned when requesting user #%d", *user.ID)
+ }
+
+ if resp2[0].Username == nil {
+ t.Errorf("Username missing or null after update")
+ } else if *resp2[0].Username != currentUsername {
+ t.Errorf("Expected Username to still be '%s', but it was '%s'",
currentUsername, *resp2[0].Username)
+ }
Review Comment:
@ocket8888 - I am not sure why the API v4 test failed.
https://github.com/apache/trafficcontrol/runs/7009420118?check_suite_focus=true
I think it failed due to some other test case.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]