[TESTS] auth LinkAccount test coverage#25663
[TESTS] auth LinkAccount test coverage#25663earl-warren wants to merge 4 commits intogo-gitea:mainfrom
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)
delvh
left a comment
There was a problem hiding this comment.
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.
I think there is no need to do so. PrepareTestEnv will reset all test data
|
|
||
| // Routes returns all web routes | ||
| func Routes() *web.Route { | ||
| func Routes(middlewares ...any) *web.Route { |
There was a problem hiding this comment.
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.
| r.Use(common.ProtocolMiddlewares()...) | ||
|
|
||
| r.Mount("/", web_routers.Routes()) | ||
| r.Mount("/", web_routers.Routes(middlewares...)) |
There was a problem hiding this comment.
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.