Don't return an empty object if Mojang's textures don't contain any skin or cape

This commit is contained in:
ErickSkrauch 2020-04-20 19:58:31 +03:00
parent 5862d1cbf6
commit 4ff164fffd
No known key found for this signature in database
GPG Key ID: 669339FCBB30EE0E
3 changed files with 18 additions and 1 deletions

View File

@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- `ely.skinsystem.{hostname}.app.mojang_textures.usernames.iteration_size` and
`ely.skinsystem.{hostname}.app.mojang_textures.usernames.queue_size` are now updates even if the queue is empty.
- Don't return an empty object if Mojang's textures don't contain any skin or cape.
### Changed
- **BREAKING**: `QUEUE_LOOP_DELAY` param is now sets as a Go duration, not milliseconds.

View File

@ -169,7 +169,10 @@ func (ctx *Skinsystem) texturesHandler(response http.ResponseWriter, request *ht
}
textures = texturesProp.Textures
// TODO: return 204 in case when there is no skin and cape on mojang textures
if textures.Skin == nil && textures.Cape == nil {
response.WriteHeader(http.StatusNoContent)
return
}
}
responseData, _ := json.Marshal(textures)

View File

@ -455,6 +455,17 @@ var texturesTestsCases = []*skinsystemTestCase{
}`, string(body))
},
},
{
Name: "Username not exists, but Mojang profile available, but there is no textures",
BeforeTest: func(suite *skinsystemTestSuite) {
suite.SkinsRepository.On("FindByUsername", "mock_username").Return(nil, nil)
suite.CapesRepository.On("FindByUsername", "mock_username").Return(nil, nil)
suite.MojangTexturesProvider.On("GetForUsername", "mock_username").Once().Return(createMojangResponse(false, false), nil)
},
AfterTest: func(suite *skinsystemTestSuite, response *http.Response) {
suite.Equal(204, response.StatusCode)
},
},
{
Name: "Username not exists and Mojang profile unavailable",
BeforeTest: func(suite *skinsystemTestSuite) {
@ -464,6 +475,8 @@ var texturesTestsCases = []*skinsystemTestCase{
},
AfterTest: func(suite *skinsystemTestSuite, response *http.Response) {
suite.Equal(204, response.StatusCode)
body, _ := ioutil.ReadAll(response.Body)
suite.Equal("", string(body))
},
},
}