mirror of
https://github.com/matrix-org/dendrite.git
synced 2024-12-02 11:11:56 -06:00
fix conversion from int to string yields a string of one rune, not a string of digits
This commit is contained in:
parent
286dd408ae
commit
6998c8248e
|
@ -1,6 +1,8 @@
|
||||||
package caching
|
package caching
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/roomserver/types"
|
"github.com/matrix-org/dendrite/roomserver/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -83,11 +85,11 @@ func (c Caches) GetRoomServerRoomNID(roomID string) (types.RoomNID, bool) {
|
||||||
|
|
||||||
func (c Caches) StoreRoomServerRoomNID(roomID string, roomNID types.RoomNID) {
|
func (c Caches) StoreRoomServerRoomNID(roomID string, roomNID types.RoomNID) {
|
||||||
c.RoomServerRoomNIDs.Set(roomID, roomNID)
|
c.RoomServerRoomNIDs.Set(roomID, roomNID)
|
||||||
c.RoomServerRoomIDs.Set(string(roomNID), roomID)
|
c.RoomServerRoomIDs.Set(strconv.Itoa(int(roomNID)), roomID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Caches) GetRoomServerRoomID(roomNID types.RoomNID) (string, bool) {
|
func (c Caches) GetRoomServerRoomID(roomNID types.RoomNID) (string, bool) {
|
||||||
val, found := c.RoomServerRoomIDs.Get(string(roomNID))
|
val, found := c.RoomServerRoomIDs.Get(strconv.Itoa(int(roomNID)))
|
||||||
if found && val != nil {
|
if found && val != nil {
|
||||||
if roomID, ok := val.(string); ok {
|
if roomID, ok := val.(string); ok {
|
||||||
return roomID, true
|
return roomID, true
|
||||||
|
|
|
@ -14,6 +14,7 @@ package transactions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/matrix-org/util"
|
"github.com/matrix-org/util"
|
||||||
|
@ -44,8 +45,8 @@ func TestCache(t *testing.T) {
|
||||||
for i := 1; i <= 100; i++ {
|
for i := 1; i <= 100; i++ {
|
||||||
fakeTxnCache.AddTransaction(
|
fakeTxnCache.AddTransaction(
|
||||||
fakeAccessToken,
|
fakeAccessToken,
|
||||||
fakeTxnID+string(i),
|
fakeTxnID+strconv.Itoa(i),
|
||||||
&util.JSONResponse{Code: http.StatusOK, JSON: fakeType{ID: string(i)}},
|
&util.JSONResponse{Code: http.StatusOK, JSON: fakeType{ID: strconv.Itoa(i)}},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue