-
Couldn't load subscription status.
- Fork 58
Fix/trim user name or email #1663
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
base: main
Are you sure you want to change the base?
Fix/trim user name or email #1663
Conversation
WalkthroughThe Changes
Sequence Diagram(s)sequenceDiagram
participant Test as TestSearchUser
participant Loader as UserLoader
participant Usecase as UserUsecase
Test->>Loader: SearchUser(nameOrEmail)
Loader->>Loader: Trim whitespace from nameOrEmail
Loader->>Usecase: SearchUser(trimmedNameOrEmail)
Usecase-->>Loader: User or nil
Loader-->>Test: User or nil
Assessment against linked issues
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (1.64.8)Error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2 ✨ Finishing Touches
🧪 Generate Unit Tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (3)
server/internal/adapter/gql/loader_user.go (1)
42-45: Inline trim & guard against empty inputThe extra temporary
trimmedvariable is unnecessary, and the method will still hit the DB even if the caller passes only whitespace.
A tiny refactor improves readability and avoids an unhelpful round-trip.- trimmed := strings.TrimSpace(nameOrEmail) - nameOrEmail = trimmed + nameOrEmail = strings.TrimSpace(nameOrEmail) + if nameOrEmail == "" { // nothing to search + return nil, nil + }server/e2e/gql_user_test.go (2)
145-165: Broaden whitespace test coverageNice conversion to table-driven tests 👏.
Consider adding a trailing-space and a both-sides-space case so the new logic is exercised symmetrically:{ name: "trimming space", input: " e2e", wantFound: true, }, + { + name: "trailing space", + input: "e2e ", + wantFound: true, + }, + { + name: "both sides space", + input: " e2e ", + wantFound: true, + },
173-181: Check GraphQL errors at the root level
errorsis a root-level field, not insidedata.
Asserting onresp.NotContainsKey("errors")after you’ve already drilled intodatawill always pass.
Capture the raw response first (before.Value("data")) or perform a second assertion on the top-level object.raw := Request(e, uId1.String(), request).Object() data := raw.Value("data").Object() // ... if !tt.wantFound { data.Value("searchUser").IsNull() raw.NotContainsKey("errors") }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
server/e2e/gql_user_test.go(1 hunks)server/internal/adapter/gql/loader_user.go(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
server/e2e/gql_user_test.go (1)
server/e2e/common.go (2)
GraphQLRequest(222-226)Request(228-239)
Overview
Fixes #225
What I’ve done
What I haven’t done
How I tested
Which point I want you to review particularly
Memo
Summary by CodeRabbit
Bug Fixes
Tests