Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
webapp-lib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CS-214
ul2024
webapp-lib
Commits
a9c088f8
Commit
a9c088f8
authored
4 months ago
by
Clément Pit-Claudel
Browse files
Options
Downloads
Patches
Plain Diff
tests: Test WebSocket response
parent
06ad831e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
jvm/src/test/scala/cs214/webapp/AppSuite.scala
+16
-5
16 additions, 5 deletions
jvm/src/test/scala/cs214/webapp/AppSuite.scala
with
16 additions
and
5 deletions
jvm/src/test/scala/cs214/webapp/AppSuite.scala
+
16
−
5
View file @
a9c088f8
...
...
@@ -30,10 +30,10 @@ object PingPongSuite:
override
val
eventFormat
=
StringWire
override
val
viewFormat
=
StringWire
override
def
init
(
clients
:
Seq
[
UserId
])
:
String
=
""
override
def
init
(
clients
:
Seq
[
UserId
])
:
String
=
"
hello
"
override
def
project
(
state
:
String
)(
userId
:
UserId
)
:
Pong
=
state
override
def
transition
(
state
:
String
)(
userId
:
UserId
,
event
:
Ping
)
:
Try
[
Seq
[
Action
[
State
]]]
=
Try
:
Seq
(
Action.Render
(
state
))
Seq
(
Action.Render
(
event
))
WebServer.register
(
PingPong
)
...
...
@@ -88,9 +88,20 @@ class WebSocketSuite extends PingPongSuite:
.
response
(
asWebSocketAlways
(
body
))
.
send
(
backend
)
test
(
"ws: The server sends a welcome message over web sockets"
)
:
test
(
"ws: The
ping
server sends a welcome message over web sockets"
)
:
withServer:
server
?=>
val
inst
=
createInstance
(
USER_IDS
)
withWs
(
inst
.
instanceId
)
:
ws
=>
val
initial
=
decodeActions
(
ws
.
receiveText
())
assertEquals
(
initial
,
Seq
(
Action
.
Render
(
""
)))
val
initial
=
decodeActions
(
ws
.
receiveText
())
assertEquals
(
initial
,
Seq
(
Action
.
Render
(
"hello"
)))
test
(
"ws: The ping server echoes events"
)
:
withServer:
server
?=>
val
inst
=
createInstance
(
USER_IDS
)
withWs
(
inst
.
instanceId
)
:
ws
=>
ws
.
receiveText
()
time
:
for
i
<-
0
to
1000
do
ws
.
sendText
(
app
.
wire
.
eventFormat
.
encode
(
i
.
toString
).
toString
)
val
resp
=
decodeActions
(
ws
.
receiveText
())
assertEquals
(
resp
,
Seq
(
Action
.
Render
(
i
.
toString
)))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment