-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
[TESTS] auth LinkAccount test coverage #25663
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
[TESTS] auth LinkAccount test coverage #25663
Conversation
(cherry picked from commit 6623630d1070c6c0f195197ad769b2aed15a50b9) (cherry picked from commit d30b9dc5b43da2ce3ecb24c0d2d1c47ea7582f65) (cherry picked from commit 8e790a6)
(cherry picked from commit c1d14c5fffeb823385b2984cfcdb3e195bfb151d) (cherry picked from commit e0e8aabc985af153cf1fcb2064c17f68ec37f3a2) (cherry picked from commit 392a415)
(cherry picked from commit e11dcc60f291f1b882a993f60f8381fe4561d6d0) use backticks to avoid backslash (cherry picked from commit 34212791eef2031ef09ea118a2ee5b98082174dc) (cherry picked from commit bde9473c69eaf6306457b4218d9704af64cb6cc8) (cherry picked from commit d4deb43)
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.
Sounds more like a E2E test for account linking than an integration test to me, but that one works too.
return func() { | ||
assert.NoError(t, user_service.DeleteUser(context.Background(), u, true)) | ||
} |
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.
I think there is no need to do so. PrepareTestEnv
will reset all test data
@@ -104,7 +104,7 @@ func ctxDataSet(args ...any) func(ctx *context.Context) { | |||
} | |||
|
|||
// Routes returns all web routes | |||
func Routes() *web.Route { | |||
func Routes(middlewares ...any) *web.Route { |
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.
middlewares ...any
introduces strange smell to the code base, no comment, and it might be abused in the future. And it's unclear what's the proper order for these middlewares, how they co-work with other middlewares.
_ = templates.HTMLRenderer() | ||
r := web.NewRoute() | ||
r.Use(common.ProtocolMiddlewares()...) | ||
|
||
r.Mount("/", web_routers.Routes()) | ||
r.Mount("/", web_routers.Routes(middlewares...)) |
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.
I can understand the logic by reading this PR, but, it will be a problem for future developers: why the "middlewares" appear here? Why it only applies to "/" ? How it co-work with others?
TBH, I do not think it is a good design.
-> Make route middleware/handler mockable #25766 defer web.RouteMockReset()
...
web.RouteMock(web.MockAfterMiddlewares, func(ctx *context.Context) {
ctx.Session.Set("linkAccountGothUser", testCase.gothUser)
}) |
No description provided.