-
Notifications
You must be signed in to change notification settings - Fork 3
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
getMeでDBを叩くように変更 #763
base: v2
Are you sure you want to change the base?
getMeでDBを叩くように変更 #763
Conversation
とりあえずこれ |
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.
まずは変数名をcamelCaseにしてください
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.
if err != nil
でreturn nil, err
とするのは忘れずにお願いします 🙏
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.
テスト頑張ってください
--- FAIL: TestHandlers_GetMe (0.00s)
--- FAIL: TestHandlers_GetMe/Success (0.00s)
user.go:95: Unexpected call to *mock_model.MockUserRepository.GetUserByID([context.Background.WithValue(sessions.contextKey, *sessions.Registry) c[76](https://github.com/traPtitech/Jomon/actions/runs/11745765123/job/32723973343?pr=763#step:8:77)069f6-ae57-40ee-be7d-b7674589867a]) at /home/runner/work/Jomon/Jomon/router/user.go:95 because: there are no expected calls of the method "GetUserByID" for that receiver
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v2 #763 +/- ##
=======================================
Coverage 25.23% 25.23%
=======================================
Files 148 147 -1
Lines 30578 30572 -6
=======================================
- Hits 7716 7715 -1
+ Misses 21986 21980 -6
- Partials 876 877 +1 ☔ View full report in Codecov by Sentry. |
ID uuid.UUID | ||
Name string | ||
DisplayName string | ||
Admin bool | ||
CreatedAt time.Time | ||
UpdatedAt time.Time | ||
DeletedAt *time.Time | ||
ID uuid.UUID `json:"id"` | ||
Name string `json:"name"` | ||
DisplayName string `json:"display_name"` | ||
Admin bool `json:"admin"` | ||
CreatedAt time.Time `json:"created_at"` | ||
UpdatedAt time.Time `json:"updated_at"` | ||
DeletedAt *time.Time `json:"deleted_at"` |
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.
この変更は必要なんでしょうか?使ってないように見えるんですが
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.
この変更がないと予想される返り値のJSONのフィールド名が小文字なのに、実際は大文字が返ってきて違いますよと言われたので変更しました。
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.
手元で実行したら、こんな感じにエラー出ました
--- FAIL: TestHandlers_GetMe (0.00s)
--- FAIL: TestHandlers_GetMe/Success (0.01s)
user_test.go:334:
Error Trace: /home/kohsuke/SysAd/Jomon/router/user_test.go:334
Error: Not equal:
expected: "{\"id\":\"7a045fc6-0a22-4b71-b989-93527fef1afc\",\"name\":\"9LcsCLBUWB7xgcntarNB\",\"display_name\":\"aRN8KgouLCcUuD9QtnUY\",\"admin\":true,\"created_at\":\"2024-11-15T00:15:44.088301571+09:00\",\"updated_at\":\"2024-11-15T00:15:44.088301571+09:00\",\"deleted_at\":null}"
actual : "{\"ID\":\"7a045fc6-0a22-4b71-b989-93527fef1afc\",\"Name\":\"9LcsCLBUWB7xgcntarNB\",\"DisplayName\":\"aRN8KgouLCcUuD9QtnUY\",\"Admin\":true,\"CreatedAt\":\"2024-11-15T00:15:44.088301571+09:00\",\"UpdatedAt\":\"2024-11-15T00:15:44.088301571+09:00\",\"DeletedAt\":null}"
Diff:
--- Expected
+++ Actual
@@ -1 +1 @@
-{"id":"7a045fc6-0a22-4b71-b989-93527fef1afc","name":"9LcsCLBUWB7xgcntarNB","display_name":"aRN8KgouLCcUuD9QtnUY","admin":true,"created_at":"2024-11-15T00:15:44.088301571+09:00","updated_at":"2024-11-15T00:15:44.088301571+09:00","deleted_at":null}
+{"ID":"7a045fc6-0a22-4b71-b989-93527fef1afc","Name":"9LcsCLBUWB7xgcntarNB","DisplayName":"aRN8KgouLCcUuD9QtnUY","Admin":true,"CreatedAt":"2024-11-15T00:15:44.088301571+09:00","UpdatedAt":"2024-11-15T00:15:44.088301571+09:00","DeletedAt":null}
Test: TestHandlers_GetMe/Success
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.
変更前はuser
の型がrouter.User
だった(model.User
ではなく)ので上手くできてたっぽいですね、ここでもそれに合わせてmodel.User
型からrouter.User
型への変換を行って欲しいです(適宜↓のようなヘルパー関数を作ってください)
package router
func userFromModelUser(u model.User) User { ... }
#725