mirror of
https://github.com/elyby/chrly.git
synced 2024-11-23 05:33:18 +05:30
Resolves #28. We didn't manage to catch this error during testing, so we're normalizing its handling and hope that this will not happen again
This commit is contained in:
parent
26042037b6
commit
98d280240e
@ -4,12 +4,12 @@ import (
|
||||
"bytes"
|
||||
"compress/zlib"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/getsentry/raven-go"
|
||||
"github.com/mediocregopher/radix.v2/pool"
|
||||
"github.com/mediocregopher/radix.v2/redis"
|
||||
"github.com/mediocregopher/radix.v2/util"
|
||||
@ -205,17 +205,10 @@ func findMojangUuidByUsername(username string, conn util.Cmder) (string, bool, e
|
||||
|
||||
data, _ := response.Str()
|
||||
parts := strings.Split(data, ":")
|
||||
// Temporary debug statement to investigate https://github.com/elyby/chrly/issues/28
|
||||
// https://github.com/elyby/chrly/issues/28
|
||||
if len(parts) < 2 {
|
||||
raven.Capture(raven.NewPacketWithExtra(
|
||||
"mojangUsernameToUuid hash contains corrupted data",
|
||||
raven.Extra{
|
||||
"rawValue": "hello world",
|
||||
"username": "this is username",
|
||||
},
|
||||
), map[string]string{})
|
||||
|
||||
return "", false, nil
|
||||
conn.Cmd("HDEL", mojangUsernameToUuidKey, key)
|
||||
return "", false, fmt.Errorf("Got unexpected response from the mojangUsernameToUuid hash: \"%s\"", data)
|
||||
}
|
||||
|
||||
timestamp, _ := strconv.ParseInt(parts[1], 10, 64)
|
||||
|
@ -357,6 +357,22 @@ func (suite *redisTestSuite) TestGetUuid() {
|
||||
resp := suite.cmd("HGET", "hash:mojang-username-to-uuid", "mock")
|
||||
suite.Require().True(resp.IsType(redis.Nil), "should cleanup expired records")
|
||||
})
|
||||
|
||||
suite.RunSubTest("exists, but corrupted record", func() {
|
||||
suite.cmd("HSET",
|
||||
"hash:mojang-username-to-uuid",
|
||||
"mock",
|
||||
"corrupted value",
|
||||
)
|
||||
|
||||
uuid, found, err := suite.Redis.GetUuid("Mock")
|
||||
suite.Require().Empty(uuid)
|
||||
suite.Require().False(found)
|
||||
suite.Require().Error(err, "Got unexpected response from the mojangUsernameToUuid hash: \"corrupted value\"")
|
||||
|
||||
resp := suite.cmd("HGET", "hash:mojang-username-to-uuid", "mock")
|
||||
suite.Require().True(resp.IsType(redis.Nil), "should cleanup expired records")
|
||||
})
|
||||
}
|
||||
|
||||
func (suite *redisTestSuite) TestStoreUuid() {
|
||||
|
Loading…
Reference in New Issue
Block a user