1
0
Fork
You've already forked forgejo
0
forked from forgejo/forgejo

Review 3 of forgejo/forgejo!12512 #3

Merged
limiting-factor merged 4 commits from oliverpool/forgejo:api-test-review into wip-api-repo-access 2026年06月14日 07:46:04 +02:00
Contributor
Copy link

I realized that the call refactor dropped the check number of args verification that was previously present.

I added it back via a staticArgs field.

I also reverted the change of passing the whole signature (it is only passing the arguments), since the function name can be computed using fun.


I then wondered why permissions was passed to call: I initially thought that this was a hint at the need of structured fixtureData... however when digging, I realized that this argument wasn't used... so I dropped it.


typos-lsp found a pasword typo.


I have run some basic cpuprofiling on the tests:

  • the test run 25% faster (15s instead of 20s) if we disable the fixture insertion (only keep the fixture cleanup). Maybe a unittest.ClearFixtureTables() method would be a good investment
  • somehow of the remaining 15s, my cpuprofile shows only 5s. The main time seems spent blocking somewhere, but I wasn't able to pinpoint where exactly. Maybe this is worth some further digging.

Overall I think that the current shape (with or without the present suggestions) is in a shape that I would be able to maintain forward!

I realized that the `call` refactor dropped the `check number of args` verification that was previously present. I added it back via a `staticArgs` field. I also reverted the change of passing the whole signature (it is only passing the arguments), since the function name can be computed using `fun`. --- I then wondered why `permissions` was passed to `call`: I initially thought that this was a hint at the need of structured fixtureData... however when digging, I realized that this argument wasn't used... so I dropped it. --- [typos-lsp](https://github.com/tekumara/typos-lsp) found a `pasword` typo. --- I have run some basic cpuprofiling on the tests: - the test run 25% faster (15s instead of 20s) if we disable the fixture insertion (only keep the fixture cleanup). Maybe a `unittest.ClearFixtureTables()` method would be a good investment - somehow of the remaining 15s, my cpuprofile shows only 5s. The main time seems spent blocking somewhere, but I wasn't able to pinpoint where exactly. Maybe this is worth some further digging. --- Overall I think that the current shape (with or without the present suggestions) is in a shape that I would be able to maintain forward!
@ -633,3 +636,2 @@
funcregisterFunctionTest(funfunc(apiv1_permissions.Context),testfunctionTest)bool{
test.call=func(t*testing.T,ctxapiv1_permissions.Context,_*apiv1_permissions.Permissions,_*fixtureData,signature[]any){
t.Logf("calling %s(ctx)",routing.GetFuncShortName(signature[0]))
shortName:=routing.GetFuncShortName(fun)
Author
Contributor
Copy link

here is my reason for reverting the args []any (from signature []any)

here is my reason for reverting the `args []any` (from `signature []any`)

It is better, indeed.

It is better, indeed.
limiting-factor marked this conversation as resolved
@ -66,3 +67,4 @@
level:=levelStringToLevel(data.Get("level"))
categories:=args[0].([]auth_model.AccessTokenScopeCategory)
t.Logf("calling TokenRequiresScopes(ctx, %v, %v)",categories,level)
apiv1_permissions.TokenRequiresScopes(ctx,categories,level)
Author
Contributor
Copy link

I think that taking categories out of the args is cleaner (than taking it from the upper level, as previously)

I think that taking `categories` out of the `args` is cleaner (than taking it from the upper level, as previously)

Agreed.

Agreed.
limiting-factor marked this conversation as resolved

@oliverpool wrote in #3 (comment):

I realized that the call refactor dropped the check number of args verification that was previously present.
I added it back via a staticArgs field.

It is better. I thought about adding it but did not because the call being responsible for calling the more elaborate functions makes it less of a debug problem.

I also reverted the change of passing the whole signature (it is only passing the arguments), since the function name can be computed using fun.

Better, good call.

I then wondered why permissions was passed to call: I initially thought that this was a hint at the need of structured fixtureData... however when digging, I realized that this argument wasn't used... so I dropped it.

IIRC I initially added it because I was not sure if it would be needed. But since it is currently not used, better not have it. Adding it later won't be a major refactor.

typos-lsp found a pasword typo.

That exists also in services/auth/method but that's for another time 😄

@oliverpool wrote in https://codeberg.org/limiting-factor/forgejo/pulls/3#issue-5800472: > I realized that the `call` refactor dropped the `check number of args` verification that was previously present. > I added it back via a `staticArgs` field. It is better. I thought about adding it but did not because the `call` being responsible for calling the more elaborate functions makes it less of a debug problem. > I also reverted the change of passing the whole signature (it is only passing the arguments), since the function name can be computed using `fun`. Better, good call. > I then wondered why `permissions` was passed to `call`: I initially thought that this was a hint at the need of structured fixtureData... however when digging, I realized that this argument wasn't used... so I dropped it. IIRC I initially added it because I was not sure if it would be needed. But since it is currently not used, better not have it. Adding it later won't be a major refactor. > [typos-lsp](https://github.com/tekumara/typos-lsp) found a `pasword` typo. That exists also in `services/auth/method` but that's for another time 😄
limiting-factor merged commit 9dc794e451 into wip-api-repo-access 2026年06月14日 07:46:04 +02:00

@oliverpool wrote in #3 (comment):

  • Maybe a unittest.ClearFixtureTables() method would be a good investment

I'll try to keep that in mind for another day 🙏

@oliverpool wrote in https://codeberg.org/limiting-factor/forgejo/pulls/3#issue-5800472: > * Maybe a `unittest.ClearFixtureTables()` method would be a good investment I'll try to keep that in mind for another day 🙏
Sign in to join this conversation.
No reviewers
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
limiting-factor/forgejo!3
Reference in a new issue
limiting-factor/forgejo
No description provided.
Delete branch "oliverpool/forgejo:api-test-review"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?