Skip to content

Commit

Permalink
Fixing tests and updating deps
Browse files Browse the repository at this point in the history
  • Loading branch information
André Hahn committed Sep 13, 2019
1 parent 0a41263 commit 931f288
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ It provides a basic development framework for distributed multiplayer games and

* [Go](https://golang.org/) >= 1.10
* [etcd](https://github.com/coreos/etcd) (used for service discovery)
* [nats](https://github.com/nats-io/go-nats) (optional, used for sending and receiving rpc, grpc implementations can be used too if prefered)
* [nats](https://github.com/nats-io/nats.go) (optional, used for sending and receiving rpc, grpc implementations can be used too if prefered)
* [docker](https://www.docker.com) (optional: used for running etcd and nats dependencies on containers)

### Installing
Expand Down
15 changes: 6 additions & 9 deletions cluster/grpc_rpc_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func TestBroadcastSessionBind(t *testing.T) {
//mockPitayaClient := protosmocks.NewMockPitayaClient(ctrl)

if table.bindingStorage != nil {
g.clientMap.Store(g.server.ID, &grpcClient{cli: mockPitayaClient})
g.clientMap.Store(g.server.ID, &grpcClient{connected: true, cli: mockPitayaClient})

g.bindingStorage = mockBindingStorage
mockBindingStorage.EXPECT().GetUserFrontendID(uid, gomock.Any()).DoAndReturn(func(u, svType string) (string, error) {
Expand All @@ -110,11 +110,9 @@ func TestBroadcastSessionBind(t *testing.T) {
mockPitayaClient.EXPECT().SessionBindRemote(gomock.Any(), gomock.Any()).Do(func(ctx context.Context, msg *protos.BindMsg) {
assert.Equal(t, uid, msg.Uid, g.server.ID, msg.Fid)
})

}

err = g.BroadcastSessionBind(uid)

if table.err != nil {
assert.EqualError(t, err, table.err.Error())
} else {
Expand Down Expand Up @@ -157,7 +155,7 @@ func TestSendKick(t *testing.T) {
assert.NoError(t, err)

if table.bindingStorage != nil {
g.clientMap.Store(table.sv.ID, &grpcClient{cli: mockPitayaClient})
g.clientMap.Store(table.sv.ID, &grpcClient{connected: true, cli: mockPitayaClient})
g.bindingStorage = table.bindingStorage
mockBindingStorage.EXPECT().GetUserFrontendID(table.userID, gomock.Any()).DoAndReturn(func(u, svType string) (string, error) {
assert.Equal(t, table.userID, u)
Expand Down Expand Up @@ -197,8 +195,8 @@ func TestSendPush(t *testing.T) {
}{
{"bindingstorage-no-fid", mockBindingStorage, &Server{
Type: "tp",
Frontend: true}, nil,
},
Frontend: true,
}, nil},
{"nobindingstorage-no-fid", nil, &Server{
Type: "tp",
Frontend: true,
Expand All @@ -218,7 +216,7 @@ func TestSendPush(t *testing.T) {
uid := "someuid"

if table.bindingStorage != nil && table.sv.ID == "" {
g.clientMap.Store(table.sv.ID, &grpcClient{cli: mockPitayaClient})
g.clientMap.Store(table.sv.ID, &grpcClient{connected: true, cli: mockPitayaClient})
g.bindingStorage = table.bindingStorage
mockBindingStorage.EXPECT().GetUserFrontendID(uid, gomock.Any()).DoAndReturn(func(u, svType string) (string, error) {
assert.Equal(t, uid, u)
Expand All @@ -231,9 +229,8 @@ func TestSendPush(t *testing.T) {
assert.Equal(t, msg.Route, "sv.svc.mth")
assert.Equal(t, msg.Data, []byte{0x01})
})

} else if table.bindingStorage == nil && table.sv.ID != "" {
g.clientMap.Store(table.sv.ID, &grpcClient{cli: mockPitayaClient})
g.clientMap.Store(table.sv.ID, &grpcClient{connected: true, cli: mockPitayaClient})
mockPitayaClient.EXPECT().PushToUser(gomock.Any(), gomock.Any()).Do(func(ctx context.Context, msg *protos.Push) {
assert.Equal(t, uid, msg.Uid)
assert.Equal(t, msg.Route, "sv.svc.mth")
Expand Down
2 changes: 1 addition & 1 deletion cluster/nats_rpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"time"

"github.com/golang/protobuf/proto"
nats "github.com/nats-io/go-nats"
nats "github.com/nats-io/nats.go"
opentracing "github.com/opentracing/opentracing-go"
"github.com/topfreegames/pitaya/config"
"github.com/topfreegames/pitaya/conn/message"
Expand Down
2 changes: 1 addition & 1 deletion cluster/nats_rpc_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"github.com/golang/mock/gomock"
"github.com/golang/protobuf/proto"
"github.com/google/uuid"
nats "github.com/nats-io/go-nats"
nats "github.com/nats-io/nats.go"
"github.com/spf13/viper"
"github.com/stretchr/testify/assert"
"github.com/topfreegames/pitaya/conn/message"
Expand Down
2 changes: 1 addition & 1 deletion cluster/nats_rpc_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ package cluster
import (
"fmt"

nats "github.com/nats-io/go-nats"
nats "github.com/nats-io/nats.go"
"github.com/topfreegames/pitaya/logger"
)

Expand Down
2 changes: 1 addition & 1 deletion cluster/nats_rpc_common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"testing"
"time"

"github.com/nats-io/go-nats"
nats "github.com/nats-io/nats.go"
"github.com/stretchr/testify/assert"
"github.com/topfreegames/pitaya/helpers"
)
Expand Down
2 changes: 1 addition & 1 deletion cluster/nats_rpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"math"

"github.com/golang/protobuf/proto"
nats "github.com/nats-io/go-nats"
nats "github.com/nats-io/nats.go"
"github.com/topfreegames/pitaya/config"
"github.com/topfreegames/pitaya/constants"
e "github.com/topfreegames/pitaya/errors"
Expand Down
2 changes: 1 addition & 1 deletion cluster/nats_rpc_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (

"github.com/golang/mock/gomock"
"github.com/golang/protobuf/proto"
nats "github.com/nats-io/go-nats"
nats "github.com/nats-io/nats.go"
"github.com/spf13/viper"
"github.com/stretchr/testify/assert"
"github.com/topfreegames/pitaya/constants"
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ require (
github.com/magiconair/properties v1.7.6 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.0 // indirect
github.com/mitchellh/mapstructure v0.0.0-20180220230111-00c29f56e238 // indirect
github.com/nats-io/gnatsd v1.1.0
github.com/nats-io/go-nats v1.4.0
github.com/nats-io/nuid v1.0.0 // indirect
github.com/nats-io/gnatsd v1.4.1
github.com/nats-io/nats-server v1.4.1
github.com/nats-io/nats.go v1.8.1
github.com/onsi/ginkgo v1.8.0 // indirect
github.com/onsi/gomega v1.5.0 // indirect
github.com/opentracing/opentracing-go v1.0.2
Expand Down Expand Up @@ -67,7 +67,7 @@ require (
github.com/ugorji/go v0.0.0-20180112141927-9831f2c3ac10 // indirect
github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18 // indirect
go.uber.org/atomic v1.3.2 // indirect
golang.org/x/net v0.0.0-20190311183353-d8887717615a
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3
golang.org/x/sync v0.0.0-20190412183630-56d357773e84 // indirect
golang.org/x/time v0.0.0-20180314180208-26559e0f760e // indirect
google.golang.org/grpc v1.21.0
Expand Down
23 changes: 23 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,25 @@ github.com/mitchellh/mapstructure v0.0.0-20180220230111-00c29f56e238 h1:+MZW2uvH
github.com/mitchellh/mapstructure v0.0.0-20180220230111-00c29f56e238/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/nats-io/gnatsd v1.1.0 h1:Yo5uA2vay3xMMDysJruJrzogJyv3MBSCYfj+pR2zTD0=
github.com/nats-io/gnatsd v1.1.0/go.mod h1:nqco77VO78hLCJpIcVfygDP2rPGfsEHkGTUk94uh5DQ=
github.com/nats-io/gnatsd v1.4.1 h1:RconcfDeWpKCD6QIIwiVFcvForlXpWeJP7i5/lDLy44=
github.com/nats-io/gnatsd v1.4.1/go.mod h1:nqco77VO78hLCJpIcVfygDP2rPGfsEHkGTUk94uh5DQ=
github.com/nats-io/go-nats v1.4.0 h1:HorYtzWLSxkmcEzAFmY6vJ20lFfeAPbrnkoAYgk8GSg=
github.com/nats-io/go-nats v1.4.0/go.mod h1:+t7RHT5ApZebkrQdnn6AhQJmhJJiKAvJUio1PiiCtj0=
github.com/nats-io/jwt v0.2.14 h1:wA50KvFz/JXGXMHRygTWsRGh/ixxgC5E3kHvmtGLNf4=
github.com/nats-io/jwt v0.2.14/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg=
github.com/nats-io/nats v1.8.1 h1:o7tj70FQaN9qP7l4bHAJGDc39Xzl/CSyu9HtkHvvx8c=
github.com/nats-io/nats-server v1.4.1 h1:Ul1oSOGNV/L8kjr4v6l2f9Yet6WY+LevH1/7cRZ/qyA=
github.com/nats-io/nats-server v1.4.1/go.mod h1:c8f/fHd2B6Hgms3LtCaI7y6pC4WD1f4SUxcCud5vhBc=
github.com/nats-io/nats.go v1.8.1 h1:6lF/f1/NN6kzUDBz6pyvQDEXO39jqXcWRLu/tKjtOUQ=
github.com/nats-io/nats.go v1.8.1/go.mod h1:BrFz9vVn0fU3AcH9Vn4Kd7W0NpJ651tD5omQ3M8LwxM=
github.com/nats-io/nkeys v0.0.2 h1:+qM7QpgXnvDDixitZtQUBDY9w/s9mu1ghS+JIbsrx6M=
github.com/nats-io/nkeys v0.0.2/go.mod h1:dab7URMsZm6Z/jp9Z5UGa87Uutgc2mVpXLC4B7TDb/4=
github.com/nats-io/nkeys v0.1.0 h1:qMd4+pRHgdr1nAClu+2h/2a5F2TmKcCzjCDazVgRoX4=
github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
github.com/nats-io/nuid v1.0.0 h1:44QGdhbiANq8ZCbUkdn6W5bqtg+mHuDE4wOUuxxndFs=
github.com/nats-io/nuid v1.0.0/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w=
github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
Expand Down Expand Up @@ -144,15 +159,20 @@ github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18 h1:MPPkRncZLN9Kh4M
github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
go.uber.org/atomic v1.3.2 h1:2Oa65PReHzfn29GpvgsYwloV9AVFHPDk8tYxt2c2tr4=
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 h1:HuIa8hRrWRSrqYzx1qI49NNxhdi2PrY7gxVSq1JjLDc=
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/net v0.0.0-20180530234432-1e491301e022 h1:MVYFTUmVD3/+ERcvRRI+P/C2+WOUimXh+Pd8LVsklZ4=
golang.org/x/net v0.0.0-20180530234432-1e491301e022/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190412183630-56d357773e84 h1:IqXQ59gzdXv58Jmm2xn0tSOR9i6HqroaOFRQ3wR/dJQ=
Expand All @@ -161,6 +181,9 @@ golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e h1:o3PsSEY8E4eXWkXrIP9YJALUk
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e h1:D5TXcfTk7xF7hvieo4QErS3qqCB4teTffacDWr7CI+0=
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/time v0.0.0-20180314180208-26559e0f760e h1:aUMCDtB7fbxaw60p2ngy69FCEzU3XpcAEpszqXsdXWg=
Expand Down
2 changes: 1 addition & 1 deletion helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/coreos/etcd/clientv3"
"github.com/coreos/etcd/integration"
"github.com/nats-io/gnatsd/server"
gnatsd "github.com/nats-io/gnatsd/test"
gnatsd "github.com/nats-io/nats-server/test"
)

// GetFreePort returns a free port
Expand Down
2 changes: 1 addition & 1 deletion session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"time"

"github.com/golang/protobuf/proto"
nats "github.com/nats-io/go-nats"
nats "github.com/nats-io/nats.go"
"github.com/topfreegames/pitaya/constants"
"github.com/topfreegames/pitaya/logger"
"github.com/topfreegames/pitaya/protos"
Expand Down
2 changes: 1 addition & 1 deletion session/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
"github.com/golang/mock/gomock"
"github.com/golang/protobuf/proto"
"github.com/google/uuid"
nats "github.com/nats-io/go-nats"
nats "github.com/nats-io/nats.go"
"github.com/stretchr/testify/assert"
"github.com/topfreegames/pitaya/constants"
"github.com/topfreegames/pitaya/helpers"
Expand Down

0 comments on commit 931f288

Please sign in to comment.