@@ -5,19 +5,19 @@ import (
55 "time"
66
77 "github.com/gorilla/websocket"
8+ "github.com/metagogs/gogs"
89 "github.com/metagogs/gogs/config"
910 "github.com/metagogs/gogs/e2e/testdata"
1011 "github.com/metagogs/gogs/e2e/testdata/fakeinternal/logic/baseworld"
1112 "github.com/metagogs/gogs/e2e/testdata/game"
1213 "github.com/metagogs/gogs/global"
13- "github.com/metagogs/gogs/session"
1414 "github.com/stretchr/testify/assert"
1515)
1616
1717var (
1818 defaultConfig = config .NewConfig ("default.yaml" )
19- testClient * client
20- testClient2 * client
19+ testClient * TestClient
20+ testClient2 * TestClient
2121 uid string
2222 uid2 string
2323)
@@ -38,10 +38,10 @@ func TestSendConnectWS(t *testing.T) {
3838 // wait for started
3939 <- started
4040 t .Log ("websocket testing" )
41- clients := []* client {}
41+ clients := []* TestClient {}
4242 // try to make 10 websocket client
4343 for i := 0 ; i < 10 ; i ++ {
44- client , err := newWSClinet ("ws://127.0.0.1:8888/base" )
44+ client , err := NewWSClinet ("ws://127.0.0.1:8888/base" )
4545 assert .Nil (t , err )
4646 clients = append (clients , client )
4747 defer client .Close ()
@@ -73,22 +73,22 @@ func TestSendConnectWS(t *testing.T) {
7373 var err error
7474 t .Log ("websocket message testing" )
7575 t .Log ("user1 login" )
76- testClient , err = newWSClinet ("ws://127.0.0.1:8888/base" )
76+ testClient , err = NewWSClinet ("ws://127.0.0.1:8888/base" )
7777 assert .Nil (t , err )
7878 go testClient .Start (t )
7979
8080 <- time .After (1 * time .Second )
8181
8282 // the session pool should only have one session
83- sessions := session .ListSessions ()
83+ sessions := gogs .ListSessions ()
8484 assert .Equal (t , 1 , len (sessions ))
8585
8686 //test send data
8787 sessions [0 ].SendData ([]byte ("hello world" ))
8888 select {
8989 case <- time .After (1 * time .Second ):
9090 t .Fatal ("server get the data timeout" )
91- case msg := <- testClient .datas :
91+ case msg := <- testClient .Datas :
9292 assert .Equal (t , "hello world" , string (msg ))
9393 }
9494
@@ -99,14 +99,14 @@ func TestSendConnectWS(t *testing.T) {
9999 joinWorld (t , testClient )
100100
101101 t .Log ("user2 login" )
102- testClient2 , err = newWSClinet ("ws://127.0.0.1:8888/base" )
102+ testClient2 , err = NewWSClinet ("ws://127.0.0.1:8888/base" )
103103 assert .Nil (t , err )
104104 go testClient2 .Start (t )
105105
106106 <- time .After (1 * time .Second )
107107
108108 // with the two users logined, we should have to sessions
109- sessions = session .ListSessions ()
109+ sessions = gogs .ListSessions ()
110110 assert .Equal (t , 2 , len (sessions ))
111111
112112 uid2 = userLogin (t , "e2e2" )
@@ -121,7 +121,7 @@ func TestSendConnectWS(t *testing.T) {
121121 select {
122122 case <- time .After (1 * time .Second ):
123123 t .Fatal ("client get the JoinWorldNotify message timeout" )
124- case msg := <- testClient .datas :
124+ case msg := <- testClient .Datas :
125125 t .Log ("client get the JoinWorldNotify message" )
126126 p , err := testdata .TestApp .MessageServer .DecodeMessage (msg )
127127 assert .Nil (t , err )
@@ -147,7 +147,7 @@ func TestSendConnectWS(t *testing.T) {
147147 select {
148148 case <- time .After (1 * time .Second ):
149149 t .Fatal ("client get t he UpdateUserInWorld message timeout" )
150- case msg := <- testClient2 .datas :
150+ case msg := <- testClient2 .Datas :
151151 t .Log ("client get the UpdateUserInWorld message" )
152152 p , err := testdata .TestApp .MessageServer .DecodeMessage (msg )
153153 assert .Nil (t , err )
@@ -165,7 +165,7 @@ func TestSendConnectWS(t *testing.T) {
165165
166166// bindUser when we create a client, we should send the BindUser message to th server
167167// to bind the user to the connection. The servet should send the BindUserSuccess message to the client
168- func bindUser (t * testing.T , sendClient * client , id string ) {
168+ func bindUser (t * testing.T , sendClient * TestClient , id string ) {
169169 t .Helper ()
170170 t .Log ("client send BindUser message" )
171171 err := sendClient .WriteMessage (websocket .BinaryMessage , encodeMessage (t , & game.BindUser {
@@ -183,7 +183,7 @@ func bindUser(t *testing.T, sendClient *client, id string) {
183183 select {
184184 case <- time .After (1 * time .Second ):
185185 t .Fatal ("client get the BindSuccess message timeout" )
186- case msg := <- sendClient .datas :
186+ case msg := <- sendClient .Datas :
187187 t .Log ("client get the BindSuccess message success" )
188188 p , err := testdata .TestApp .MessageServer .DecodeMessage (msg )
189189 assert .Nil (t , err )
@@ -194,7 +194,7 @@ func bindUser(t *testing.T, sendClient *client, id string) {
194194
195195// joinWorld user can send the JoinWorld message to the server to join the world
196196// the server should send the JoinWorldSuccess message to the client
197- func joinWorld (t * testing.T , sendClient * client ) {
197+ func joinWorld (t * testing.T , sendClient * TestClient ) {
198198 t .Helper ()
199199 t .Log ("client send JoinWorld message" )
200200 err := sendClient .WriteMessage (websocket .BinaryMessage , encodeMessage (t , & game.JoinWorld {
@@ -211,7 +211,7 @@ func joinWorld(t *testing.T, sendClient *client) {
211211 select {
212212 case <- time .After (1 * time .Second ):
213213 t .Fatal ("client get the JoinWorldSuccess message timeout" )
214- case msg := <- sendClient .datas :
214+ case msg := <- sendClient .Datas :
215215 t .Log ("client get the JoinWorldSuccess message success" )
216216 p , err := testdata .TestApp .MessageServer .DecodeMessage (msg )
217217 assert .Nil (t , err )
0 commit comments