diff --git a/app/user_test.go b/app/user_test.go index b81a793fb9..060f91db9a 100644 --- a/app/user_test.go +++ b/app/user_test.go @@ -522,7 +522,11 @@ func TestUpdateUserEmail(t *testing.T) { require.Eventually(t, func() bool { var err error tokens, err = th.App.Srv().Store.Token().GetAllTokensByType(TokenTypeVerifyEmail) - return err == nil && len(tokens) == 1 + // We verify the same conditions as the earlier function, + // but we also need to ensure that this is not the same token + // as before, which is possible if the token updation goroutine + // hasn't yet run. + return err == nil && len(tokens) == 1 && tokens[0].Token != firstToken.Token }, 100*time.Millisecond, 10*time.Millisecond) secondToken := tokens[0]