Skip to content

Conversation

ookura-mf
Copy link

No description provided.

Copy link
Owner

@mf-sakura mf-sakura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

golintが通らない箇所があるので、それだけコメントしました。

Comment on lines +55 to +60
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())
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +62 to +67
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())
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +112 to +120
{
name: "ユーザー名が空",
fields: fields{
db: nil,
repository: &mockUserRepository{},
},
args: args{c: noNameUserContext()},
wantErr: true,
},
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +150 to +165
{
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,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +45 to +47
userIds := make([]int, len(r.users))
index := 0
for userId := range r.users {
Copy link
Owner

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

なるほど 👀
確かに他の箇所は ID 表記ですね

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants