-
Notifications
You must be signed in to change notification settings - Fork 25
第8回の課題(大倉) #45
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: master
Are you sure you want to change the base?
第8回の課題(大倉) #45
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.
golintが通らない箇所があるので、それだけコメントしました。
func noNameUserContext() echo.Context { | ||
e := echo.New() | ||
invalidReq := httptest.NewRequest(http.MethodPost, "/users", strings.NewReader(noNameUserJSON)) | ||
invalidReq.Header.Set(echo.HeaderContentType, echo.MIMEApplicationJSON) | ||
return e.NewContext(invalidReq, httptest.NewRecorder()) | ||
} |
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.
👍
func indexContext() echo.Context { | ||
e := echo.New() | ||
validReq := httptest.NewRequest(http.MethodGet, "/users", nil) | ||
validReq.Header.Set(echo.HeaderContentType, echo.MIMEApplicationJSON) | ||
return e.NewContext(validReq, httptest.NewRecorder()) | ||
} |
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.
👍
{ | ||
name: "ユーザー名が空", | ||
fields: fields{ | ||
db: nil, | ||
repository: &mockUserRepository{}, | ||
}, | ||
args: args{c: noNameUserContext()}, | ||
wantErr: true, | ||
}, |
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.
👍
{ | ||
name: "正常系", | ||
fields: fields{ | ||
db: nil, | ||
repository: &mockUserRepository{}, | ||
}, | ||
args: args{c: indexContext()}, | ||
}, | ||
{ | ||
name: "異常系", | ||
fields: fields{ | ||
db: nil, | ||
repository: &mockUserRepository{isError: true}, | ||
}, | ||
args: args{c: indexContext()}, | ||
wantErr: true, |
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.
👍
userIds := make([]int, len(r.users)) | ||
index := 0 | ||
for userId := range r.users { |
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.
golintに以下の様な怒られ方をするので、userID, userIDsにするのが良いと思います。
IDは固有名詞の様なものなので、IdではなくIDが推奨だと思われます。
$ golint ./interface/api/interfaces/database/user_local_repository.go
./interface/api/interfaces/database/user_local_repository.go:47:6: range var userId should be userID
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.
なるほど 👀
確かに他の箇所は ID 表記ですね
No description provided.