Skip to content

[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

Closed

Conversation

earl-warren
Copy link
Contributor

No description provided.

(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)
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jul 3, 2023
Copy link
Member

@delvh delvh left a 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.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jul 7, 2023
@GiteaBot GiteaBot added lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jul 7, 2023
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged labels Jul 8, 2023
Comment on lines +254 to +256
return func() {
assert.NoError(t, user_service.DeleteUser(context.Background(), u, true))
}
Copy link
Contributor

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 {
Copy link
Contributor

@wxiaoguang wxiaoguang Jul 8, 2023

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...))
Copy link
Contributor

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.

@wxiaoguang
Copy link
Contributor

-> Make route middleware/handler mockable #25766

defer web.RouteMockReset()
...
web.RouteMock(web.MockAfterMiddlewares, func(ctx *context.Context) {
	ctx.Session.Set("linkAccountGothUser", testCase.gothUser)
})

@go-gitea go-gitea locked as resolved and limited conversation to collaborators Nov 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/need 1 This PR needs approval from one additional maintainer to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants