Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .scala-steward.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ updates.ignore = [
{groupId = "org.scala-lang", artifactId = "scala-compiler", version = "3."}
]
updates.pin = [
{groupId = "org.scala-lang", artifactId = "scala3-library", version = "3.3."},
{groupId = "org.scala-lang", artifactId = "scala3-library_sjs1", version = "3.3."},
{groupId = "org.scala-lang", artifactId = "scala3-library", version = "3.9."},
{groupId = "org.scala-lang", artifactId = "scala3-library_sjs1", version = "3.9."},
{groupId = "com.typesafe.akka", version = "2.6."}
]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Add the following dependency:
"com.softwaremill.sttp.shared" %% "core" % "1.5.3"
```

sttp-shared is available for Scala 2.12, 2.13, 3.3, Scala.JS and Scala Native.
sttp-shared is available for Scala 2.12, 2.13, 3.9, Scala.JS and Scala Native.

### Building & testing the scala-native version

Expand Down
7 changes: 4 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ val scala2_12 = "2.12.21"
val scala2_13 = "2.13.18"
val scala2 = List(scala2_12, scala2_13)
val scala2alive = List(scala2_12, scala2_13)
val scala3 = List("3.3.8")
val scala3 = List("3.9.0")
val akkaVersion = "2.6.20"
val pekkoVersion = "1.7.1"
val sttpModelVersion = "1.8.2"
Expand Down Expand Up @@ -36,7 +36,7 @@ versionScheme := Some("semver-spec")

val commonJvmSettings = Seq(
scalacOptions ++=
(if (ScalaArtifacts.isScala3(scalaVersion.value)) Seq("-Yfuture-lazy-vals", "-java-output-version", "11")
(if (ScalaArtifacts.isScala3(scalaVersion.value)) Seq("-java-output-version", "17")
else Seq("-release", "8")),
ideSkipProject := (scalaVersion.value != scala2_13),
bspEnabled := !ideSkipProject.value,
Expand Down Expand Up @@ -118,7 +118,8 @@ lazy val core = (projectMatrix in file("core"))
lazy val ws = (projectMatrix in file("ws"))
.settings(
name := "ws",
libraryDependencies += "com.softwaremill.sttp.model" %% "core" % sttpModelVersion
libraryDependencies += "com.softwaremill.sttp.model" %% "core" % sttpModelVersion,
scalacOptions ++= (if (ScalaArtifacts.isScala3(scalaVersion.value)) Nil else Seq("-Xsource:3"))
)
.jvmPlatform(
scalaVersions = scala2 ++ scala3,
Expand Down
2 changes: 1 addition & 1 deletion ws/src/main/scala/sttp/ws/WebSocket.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ trait WebSocket[F[_]] {
* @param pongOnPing
* Should a [[WebSocketFrame.Pong]] be sent when a [[WebSocketFrame.Ping]] is received.
*/
def receiveDataFrame(pongOnPing: Boolean = true): F[WebSocketFrame.Data[_]] =
def receiveDataFrame(pongOnPing: Boolean = true): F[WebSocketFrame.Data[?]] =
receive().flatMap {
case close: WebSocketFrame.Close => monad.error(WebSocketClosed(Some(close)))
case d: WebSocketFrame.Data[_] => monad.unit(d)
Expand Down
18 changes: 11 additions & 7 deletions ws/src/test/scala/sttp/ws/testing/WebSocketStubTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ import sttp.ws.{WebSocketClosed, WebSocketFrame}

import scala.util.{Failure, Success}
import sttp.monad.IdentityMonad
import sttp.shared.Identity

class WebSocketStubTests extends AnyFlatSpec with Matchers with ScalaFutures {
class MyException extends Exception

private implicit val identityMonad: MonadError[Identity] = IdentityMonad

"web socket stub" should "return initial Incoming frames on 'receive'" in {
val frames = List("a", "b", "c").map(WebSocketFrame.text)
val webSocketStub = WebSocketStub.initialReceive(frames)
val ws = webSocketStub.build(IdentityMonad)
val ws = webSocketStub.build[Identity]

ws.receive() shouldBe WebSocketFrame.text("a")
ws.receive() shouldBe WebSocketFrame.text("b")
Expand All @@ -26,7 +29,7 @@ class WebSocketStubTests extends AnyFlatSpec with Matchers with ScalaFutures {
val okFrame = WebSocketFrame.text("abc")
val exception = new MyException
val webSocketStub = WebSocketStub.initialReceiveWith(List(Success(okFrame), Failure(exception)))
val ws = webSocketStub.build(IdentityMonad)
val ws = webSocketStub.build[Identity]

ws.receive() shouldBe WebSocketFrame.text("abc")
assertThrows[MyException](ws.receive())
Expand All @@ -43,7 +46,7 @@ class WebSocketStubTests extends AnyFlatSpec with Matchers with ScalaFutures {
case `expectedFrame` => List(secondFrame, thirdFrame)
case _ => List.empty
}
val ws = webSocketStub.build(IdentityMonad)
val ws = webSocketStub.build[Identity]

ws.receive() shouldBe WebSocketFrame.text("No. 1")
assertThrows[IllegalStateException](ws.receive()) // no more stubbed messages
Expand All @@ -60,7 +63,7 @@ class WebSocketStubTests extends AnyFlatSpec with Matchers with ScalaFutures {

val webSocketStub = WebSocketStub.noInitialReceive
.thenRespondWith(_ => List(Success(ok), Failure(exception)))
val ws = webSocketStub.build(IdentityMonad)
val ws = webSocketStub.build[Identity]

ws.send(WebSocketFrame.text("let's add responses"))
ws.receive() shouldBe WebSocketFrame.text("ok")
Expand All @@ -71,7 +74,7 @@ class WebSocketStubTests extends AnyFlatSpec with Matchers with ScalaFutures {
val ok = WebSocketFrame.text("ok")
val closeFrame = WebSocketFrame.Close(500, "internal error")
val webSocketStub = WebSocketStub.initialReceive(List(closeFrame, ok))
val ws = webSocketStub.build(IdentityMonad)
val ws = webSocketStub.build[Identity]

ws.send(WebSocketFrame.text("let's add responses"))
ws.receive() shouldBe closeFrame
Expand All @@ -84,7 +87,7 @@ class WebSocketStubTests extends AnyFlatSpec with Matchers with ScalaFutures {
.thenRespondS(0) { case (counter, _) =>
(counter + 1, List(WebSocketFrame.text(s"No. $counter")))
}
val ws = webSocketStub.build(IdentityMonad)
val ws = webSocketStub.build[Identity]

ws.send(WebSocketFrame.text("a"))
ws.send(WebSocketFrame.text("b"))
Expand Down Expand Up @@ -115,7 +118,8 @@ class WebSocketStubTests extends AnyFlatSpec with Matchers with ScalaFutures {

"receive" should "be lazy" in {
// given
val ws = WebSocketStub.noInitialReceive.thenRespond(_ => List(WebSocketFrame.text("test"))).build(LazyMonad)
implicit val lazyMonad: MonadError[() => *] = LazyMonad
val ws = WebSocketStub.noInitialReceive.thenRespond(_ => List(WebSocketFrame.text("test"))).build[() => *]

// when
val doReceive = ws.receive() // should return a lazy receive
Expand Down
Loading