mirror of
https://github.com/elyby/chrly.git
synced 2024-12-23 13:40:11 +05:30
#1: Fix GolangCI issues
This commit is contained in:
parent
90ce22f687
commit
6daec4dc4b
@ -254,7 +254,7 @@ func (suite *queueTestSuite) TestReceiveTexturesForUsernameWithCachedUnknownUuid
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *queueTestSuite) TestReceiveTexturesForMoreThan100Usernames() {
|
func (suite *queueTestSuite) TestReceiveTexturesForMoreThan100Usernames() {
|
||||||
usernames := make([]string, 120, 120)
|
usernames := make([]string, 120)
|
||||||
for i := 0; i < 120; i++ {
|
for i := 0; i < 120; i++ {
|
||||||
usernames[i] = randStr(8)
|
usernames[i] = randStr(8)
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ func TestConfig_PostSkin(t *testing.T) {
|
|||||||
writer := multipart.NewWriter(body)
|
writer := multipart.NewWriter(body)
|
||||||
|
|
||||||
part, _ := writer.CreateFormFile("skin", "char.png")
|
part, _ := writer.CreateFormFile("skin", "char.png")
|
||||||
part.Write(loadSkinFile())
|
_, _ = part.Write(loadSkinFile())
|
||||||
|
|
||||||
_ = writer.WriteField("identityId", "1")
|
_ = writer.WriteField("identityId", "1")
|
||||||
_ = writer.WriteField("username", "mock_user")
|
_ = writer.WriteField("username", "mock_user")
|
||||||
@ -332,7 +332,7 @@ func TestConfig_PostSkin(t *testing.T) {
|
|||||||
req.Header.Add("Authorization", "Bearer invalid.jwt.token")
|
req.Header.Add("Authorization", "Bearer invalid.jwt.token")
|
||||||
w := httptest.NewRecorder()
|
w := httptest.NewRecorder()
|
||||||
|
|
||||||
mocks.Auth.EXPECT().Check(gomock.Any()).Return(&auth.Unauthorized{"Cannot parse passed JWT token"})
|
mocks.Auth.EXPECT().Check(gomock.Any()).Return(&auth.Unauthorized{Reason: "Cannot parse passed JWT token"})
|
||||||
mocks.Log.EXPECT().IncCounter("authentication.challenge", int64(1))
|
mocks.Log.EXPECT().IncCounter("authentication.challenge", int64(1))
|
||||||
mocks.Log.EXPECT().IncCounter("authentication.failed", int64(1))
|
mocks.Log.EXPECT().IncCounter("authentication.failed", int64(1))
|
||||||
|
|
||||||
@ -389,7 +389,7 @@ func TestConfig_DeleteSkinByUserId(t *testing.T) {
|
|||||||
w := httptest.NewRecorder()
|
w := httptest.NewRecorder()
|
||||||
|
|
||||||
mocks.Auth.EXPECT().Check(gomock.Any()).Return(nil)
|
mocks.Auth.EXPECT().Check(gomock.Any()).Return(nil)
|
||||||
mocks.Skins.EXPECT().FindByUserId(2).Return(nil, &db.SkinNotFoundError{"unknown"})
|
mocks.Skins.EXPECT().FindByUserId(2).Return(nil, &db.SkinNotFoundError{Who: "unknown"})
|
||||||
mocks.Log.EXPECT().IncCounter("authentication.challenge", int64(1))
|
mocks.Log.EXPECT().IncCounter("authentication.challenge", int64(1))
|
||||||
mocks.Log.EXPECT().IncCounter("authentication.success", int64(1))
|
mocks.Log.EXPECT().IncCounter("authentication.success", int64(1))
|
||||||
mocks.Log.EXPECT().IncCounter("api.skins.delete.request", int64(1))
|
mocks.Log.EXPECT().IncCounter("api.skins.delete.request", int64(1))
|
||||||
@ -448,7 +448,7 @@ func TestConfig_DeleteSkinByUsername(t *testing.T) {
|
|||||||
w := httptest.NewRecorder()
|
w := httptest.NewRecorder()
|
||||||
|
|
||||||
mocks.Auth.EXPECT().Check(gomock.Any()).Return(nil)
|
mocks.Auth.EXPECT().Check(gomock.Any()).Return(nil)
|
||||||
mocks.Skins.EXPECT().FindByUsername("mock_user_2").Return(nil, &db.SkinNotFoundError{"mock_user_2"})
|
mocks.Skins.EXPECT().FindByUsername("mock_user_2").Return(nil, &db.SkinNotFoundError{Who: "mock_user_2"})
|
||||||
mocks.Log.EXPECT().IncCounter("authentication.challenge", int64(1))
|
mocks.Log.EXPECT().IncCounter("authentication.challenge", int64(1))
|
||||||
mocks.Log.EXPECT().IncCounter("authentication.success", int64(1))
|
mocks.Log.EXPECT().IncCounter("authentication.success", int64(1))
|
||||||
mocks.Log.EXPECT().IncCounter("api.skins.delete.request", int64(1))
|
mocks.Log.EXPECT().IncCounter("api.skins.delete.request", int64(1))
|
||||||
@ -482,7 +482,7 @@ func TestConfig_Authenticate(t *testing.T) {
|
|||||||
mocks.Log.EXPECT().IncCounter("authentication.challenge", int64(1))
|
mocks.Log.EXPECT().IncCounter("authentication.challenge", int64(1))
|
||||||
mocks.Log.EXPECT().IncCounter("authentication.failed", int64(1))
|
mocks.Log.EXPECT().IncCounter("authentication.failed", int64(1))
|
||||||
|
|
||||||
res := config.Authenticate(http.HandlerFunc(func (resp http.ResponseWriter, req *http.Request) {}))
|
res := config.Authenticate(http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {}))
|
||||||
res.ServeHTTP(w, req)
|
res.ServeHTTP(w, req)
|
||||||
|
|
||||||
resp := w.Result()
|
resp := w.Result()
|
||||||
|
@ -16,7 +16,7 @@ func (cfg *Config) Cape(response http.ResponseWriter, request *http.Request) {
|
|||||||
rec, err := cfg.CapesRepo.FindByUsername(username)
|
rec, err := cfg.CapesRepo.FindByUsername(username)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
request.Header.Set("Content-Type", "image/png")
|
request.Header.Set("Content-Type", "image/png")
|
||||||
io.Copy(response, rec.File)
|
_, _ = io.Copy(response, rec.File)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user